Postgresql 9.4 - pg_largeobject大小与存储对象的大小不对应?

时间:2016-05-31 10:17:29

标签: database postgresql size vacuum

我有一个大约43GB的数据库。当我计算大小的pg_largeobject表时,它也给了我 43GB

SELECT pg_size_pretty(pg_table_size('pg_largeobject'));    

当我通过以下命令对所有大型对象的大小求和时:

SELECT sum(length(pg.data)) FROM pg_largeobject pg;

它给了我 32.5GB 。我试图通过以下方式取消与所需对象之间的所有对象的链接:

SELECT lo_unlink(l.loid)
FROM   pg_largeobject l
GROUP  BY loid
HAVING (NOT EXISTS (SELECT 1 FROM data_file t WHERE t.file_content = l.loid))
AND    (NOT EXISTS (SELECT 1 FROM license t WHERE t.attachment_content = l.loid))
AND    (NOT EXISTS (SELECT 1 FROM personal_license t WHERE t.attachment_content = l.loid))
AND    (NOT EXISTS (SELECT 1 FROM scenario t WHERE t.scenario_file = l.loid))
AND    (NOT EXISTS (SELECT 1 FROM service_result t WHERE t.content = l.loid));

并运行VACUUM:

VACUUM FULL ANALYZE pg_largeobject;

当我尝试一次时,它将大小从47GB缩小到43但我找不到丢失的10.5 GB 你知道那里可以存储什么或我应该怎么做?

0 个答案:

没有答案