gpt4 book ai didi

postgresql - postgres 数据库中表的大小异常增长

转载 作者:行者123 更新时间:2023-11-29 14:06:11 25 4
gpt4 key购买 nike

我们的一个数据库大小是 50gb。其中一张表有 149444622 条记录。该表的大小为 14GB,其索引大小为 16GB。表及其索引的总大小为 30GB。我已对该表执行了以下步骤。

reindex table table_name;

vacuum full verbose analyze on table_name;

但表的大小及其索引的大小仍然没有减少。请指导我。如何进一步进行。

表格结构如下。

enter image description here

最佳答案

14 GB 对你的数据来说没有异常。让我们计算一下。

简单地将列的大小相加得到每列 68 个字节。

2 bigints @ 8 bytes each    16 bytes
4 integers @ 4 bytes each 16 bytes
4 doubles @ 8 bytes each 32 bytes
1 date @ 4 bytes 4 bytes
--------
68 bytes

149,444,622,每个 68 字节大约 9.7 GB。如果没有数据库开销,这是数据的绝对最小大小。 But there is overhead . This answer reckons its about 28 bytes per row . 68 + 28 是每行 96 个字节。这将我们带到... 14.3 GB。正是您所拥有的。


我怀疑您是否可以在不更改模式、删除索引或删除数据的情况下减小大小。如果您提供了有关您的架构的更多详细信息,我们可以提供建议,但我建议您将其作为一个新问题。

最后,请考虑 50 GB 是一个非常小的数据库。例如,the smallest paid database offered by Heroku是 64 GB,每月只需 50 美元。这种情况可能只需要使用更大的磁盘就可以了。

关于postgresql - postgres 数据库中表的大小异常增长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52022988/

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