如何使用 PostgreSQL 执行真空?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4759503/
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
How can I perform the vacuum using the PostgreSQL?
提问by Adalarasan Sachithanantham
I need to vacuum the PostgreSQL database in production server. I am very new to do this. So anybody knows the PostgreSQL steps, please guide me.
我需要清理生产服务器中的 PostgreSQL 数据库。我很新来做这件事。所以有人知道PostgreSQL的步骤,请指导我。
I think it's very useful to improve the performance of PostgreSQL in production server.
我认为在生产服务器中提高 PostgreSQL 的性能非常有用。
回答by Ken Downs
Connect to the database and issue this command: "VACUUM". This causes a run in "lazy mode" that can be used during normal production use. It is recommended you actually invoke it as "vacuum analyze" which will also update statistics.
连接到数据库并发出以下命令:“VACUUM”。这会导致在正常生产使用期间可以使用的“惰性模式”运行。建议您实际调用它作为“真空分析”,这也将更新统计信息。
If you want to see lots of detail, you can at the console type "vacuum verbose"
如果你想看到很多细节,你可以在控制台输入“vacuum verbose”
The more extreme form is "vacuum full" which causes heavy table locking and cannot really be used on a production system.
更极端的形式是“vacuum full”,这会导致严重的表锁定并且不能真正用于生产系统。
Source: http://www.postgresql.org/docs/8.1/static/maintenance.html
来源:http: //www.postgresql.org/docs/8.1/static/maintenance.html
回答by Frank Wiles
If you're running a recent version of PostgreSQL you likely have auto-vacuum running so the benefits of running VACUUM manually may be very minimal.
如果您运行的是最新版本的 PostgreSQL,您可能会运行 auto-vacuum,因此手动运行 VACUUM 的好处可能非常小。