gpt4 book ai didi

postgresql - 在 Postgres 9.4 上 vacuum full 后我需要重新索引吗

转载 作者:行者123 更新时间:2023-11-29 11:08:43 24 4
gpt4 key购买 nike

我正在使用 Postgres 9.4。

我刚用完真空吸尘器。我了解了 vacuum 和 vacuum full 之间的区别,并且考虑了很多我应该运行 vacuum 还是 vacuum full。据我所知,我需要 vacuum full,我的数据库大小从 48 GB 下降到 24 GB。

旧索引在 vacuum full 后是否会过时,我是否需要运行 reindex?

我运行了“vacuum full verbose analyze”,所以分析是与 vacuum full 一起完成的。

我在几个地方读到,对于 Postgres > 9.0,我不需要在 vacuum full 后重新索引,但我想确保情况确实如此。

最佳答案

紧接在 VACUUM FULL 之后的 REINDEX无用的,因为 VACUUM FULL 本身会重建索引。

Recovering Disk Space 中的 9.4 文档中提到了这一点:

...to reclaim the excess disk space it occupies, you will need to use VACUUM FULL, or alternatively CLUSTER or one of the table-rewriting variants of ALTER TABLE. These commands rewrite an entire new copy of the table and build new indexes for it.

你是对的,在 9.0 版之前情况并非如此,它以不同的方式重新实现了 VACUUM FULL

到版本 8.4,VACUUM 的引用文档提到需要重建索引:

The FULL option does not shrink indexes; a periodic REINDEX is still recommended. In fact, it is often faster to drop all indexes, VACUUM FULL, and recreate the indexes.

但是这个警告现在已经过时了。

关于postgresql - 在 Postgres 9.4 上 vacuum full 后我需要重新索引吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31009597/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com