Dead Tuples without updates/deletes

一世执手 提交于 2021-01-20 06:45:51

问题


Is it possible? I have a table with fast growing dead tuples, but I can't see any update or delete to the table during the day, just inserts and selects. Autovacuum runs each 10 min, the n_dead_tup goes almost to zero and start growing again.

There is one delete at this table, for purging rows with date 15 days ago, running only once per day (triple-checked that is done just once per day).

In the rest of the day, only inserts and selects run on this table.


回答1:


A failed attempt to insert data may cause dead tuples. Example:

create table test(id serial primary key, str text);

insert into test (str) values ('abc');

select pg_stat_get_dead_tuples('test'::regclass);

 pg_stat_get_dead_tuples 
-------------------------
                       0
(1 row)

insert into test values (1, 'def');

ERROR:  duplicate key value violates unique constraint "test_pkey"
DETAIL:  Key (id)=(1) already exists.

select pg_stat_get_dead_tuples('test'::regclass);

 pg_stat_get_dead_tuples 
-------------------------
                       1
(1 row)

This also applies to the inserts aborted due to rollback.



来源:https://stackoverflow.com/questions/41642931/dead-tuples-without-updates-deletes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!