5

最近,我为生产创建了一个新的 Heroku 应用程序,并用我从暂存数据库中获取的备份填充了它的数据库。

问题是两个数据库的数据库大小不同,如 Heroku 的 Postgres 网页所示!

我从中进行备份的第一个数据库是 360 MB,而填充的新数据库只有 290 MB。

在备份/加载过程中没有出现错误。并从两个数据库进行备份会产生相同的备份文件大小(大约 40 MB)。

该项目运行良好,两个应用程序看起来完全一样,但我担心我可能会丢失一些数据,这会在未来造成麻烦。

更多信息:我在两个应用程序上使用相同的生产数据库计划。

此外,第一个数据库未附加到第一个实例(因为它是从 Postgres 管理页面添加的,而不是从应用程序的资源页面添加的),并且新数据库附加到新应用程序。

提前致谢

4

2 回答 2

8

postgresql DB 在使用时消耗更多空间是可以的。

The reason of this is its MVCC system. Every time you UPDATE any record in a database it creates another "version" of this record instead of rewriting the previous. This "outdated" records will be deleted by VACUUM process, when there will be no need in them.

So, when you restored your db from backup, it didn't have any "dead" records and its size was less.

Details here http://www.postgresql.org/docs/current/static/mvcc.html and http://www.postgresql.org/docs/current/static/sql-vacuum.html.

P.S. You do not need to worry about it. Postgresql will handle VACUUM automatically.

于 2012-11-22T08:32:07.947 回答
0

看看这是否有帮助:PostgreSQL 数据库大小增加

还尝试单独测量每个表的大小,对于那些您看到差异的表,比较记录数:postgresql 数据库总大小与单个表大小的总和不匹配

于 2012-11-22T04:26:59.650 回答