简体   繁体   English

创建临时表不会导致pg_class表碎片

[英]Does creating a temp table cause the pg_class table to fragment

MS-SQL developer on this end working in a Postgres shop (PG 8.4 and PG 9.4) 为此,MS-SQL开发人员在Postgres商店中工作(PG 8.4和PG 9.4)

Another developer mentioned as a reason for not using temp tables in Postgres SQL is that it will cause fragmentation in the Postgres system tables (pg_class specifically) leading to performance degradation. 提到的另一个在Postgres SQL中不使用临时表的原因是,这将导致Postgres系统表(特别是pg_class)中的碎片,从而导致性能下降。 Is this true? 这是真的?

Cheers 干杯

Fragmentation is a rather meaningless term when applied to a database table, as they always consist of blocks of a fixed size (8 KB in PostgreSQL). 当将碎片应用于数据库表时,它是一个毫无意义的术语,因为它们始终由固定大小的块(PostgreSQL中为8 KB)组成。

What is true is that using a temporary table will create entries in system catalog tables and indexes like pg_class which will be deleted when the temporary table goes away. 确实,使用临时表将在系统目录表和pg_class索引中创建条目,当临时表消失时,这些条目将被删除。 If you do a lot of that, the same thing could happen as with any other table that is heavily updated: autovacuum may not be able to keep up, and your system catalog tables and their indexes might get bloated. 如果执行大量操作 ,则可能会发生与其他任何表进行大量更新的情况相同的情况:自动清理可能无法跟上,并且系统目录表及其索引可能会膨胀。

There is a proposal on pgsql-hackers right now to invent a new kind of temporary table that avoids this kind of problem. 现在有一个关于pgsql-hackers的建议 ,发明一种避免这种问题的新型临时表。

However, unless you use really a lot of temporary tables all the time, there is no need to worry. 但是,除非您一直真正使用大量临时表,否则不必担心。 Just use them when you need to! 只需在需要时使用它们即可!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM