postgresql 我是否需要在 Postgres 9.4 上的真空充满后重新索引
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31009597/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Do I need to reindex after vacuum full on Postgres 9.4
提问by Akshar Raaj
I am using Postgres 9.4.
我正在使用 Postgres 9.4。
I just ran vacuum full. I read about the differences between vacuum and vacuum full and considered a lot if I should run vacuum or vacuum full. As far as I can say, I required vacuum full and my db size came down from 48 GB to 24 GB.
我刚跑完真空。我阅读了真空和全真空之间的区别,并考虑了很多我是否应该运行真空或真空全。据我所知,我需要完全真空,并且我的数据库大小从 48 GB 降至 24 GB。
Would the old indexes would have become obsolete after vacuum full and do I need to run reindex?
真空已满后旧索引是否会过时,我是否需要运行重新索引?
I ran "vacuum full verbose analyze", so analyze is done along with vacuum full.
我运行了“vacuum full verbose analysis”,所以分析是与真空完整一起完成的。
I read at several places that for Postgres > 9.0, I don't need reindex after vacuum full, but I want to be sure that it is the case.
我在几个地方读到 Postgres > 9.0,我不需要在真空充满后重新索引,但我想确定情况确实如此。
回答by Daniel Vérité
A REINDEX
immediately after a VACUUM FULL
is uselessbecause VACUUM FULL
itself rebuilds the indexes.
一个REINDEX
后一个VACUUM FULL
是没用的,因为VACUUM FULL
本身重建索引。
This is mentioned in the 9.4 documentation in Recovering Disk Space:
这在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.
...要回收它占用的多余磁盘空间,您需要使用 VACUUM FULL,或者 CLUSTER 或 ALTER TABLE 的表重写变体之一。这些命令重写表的整个新副本并为其构建新索引。
You are correct that this was not the case before version 9.0, which had VACUUM FULL
reimplemented differently.
你是对的,在 9.0 版之前不是这种情况,它以 VACUUM FULL
不同的方式重新实现。
Up to version 8.4, the reference doc for VACUUMmentioned the need to reindex:
在 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.
FULL 选项不会收缩索引;仍然建议定期进行 REINDEX。事实上,删除所有索引、VACUUM FULL 并重新创建索引通常更快。
But this caveat is now obsolete.
但是这个警告现在已经过时了。