如何缩小 postgresql 数据库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36019147/
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 shrink a postgresql database?
提问by Kearl
I have an instance of Postgresql that is 374GB!
我有一个 374GB 的 Postgresql 实例!
It's the dbase for an Event Sentry Application, but since Event Sentry is just a monitoring tool, don't see how it can require this much data.
There are hundreds of 1 Gig files in the default database folder.
Any assistance on this one is greatly appreciated! Carl
它是 Event Sentry 应用程序的数据库,但由于 Event Sentry 只是一个监控工具,所以看不出它如何需要这么多数据。默认数据库文件夹中有数百个 1 Gig 文件。非常感谢对此的任何帮助!卡尔
回答by Rodrigo Hjort
Take a look at this operation called 'vacuum' in PostgreSQL:
看看 PostgreSQL 中这个叫做“vacuum”的操作:
http://www.postgresql.org/docs/9.5/static/routine-vacuuming.html
http://www.postgresql.org/docs/9.5/static/routine-vacuuming.html
However, in some situations even vacuuming doesn't solve that much. In that case, the best to do is make a dump, recreate the database and restore it.
然而,在某些情况下,即使是吸尘也不能解决那么多问题。在这种情况下,最好的办法是进行转储,重新创建数据库并恢复它。