有可能吗?我有一个快速增长的死元组的表,但我在白天看不到任何更新或删除表,只是插入和选择。 Autovacuum每10分钟运行一次,n_dead_tup几乎变为零并再次开始增长。
此表中有一个删除,用于清除15天前的日期行,每天只运行一次(三次检查,每天只执行一次)。
在当天的剩余时间里,只有插入和选择在此表上运行。
答案 0 :(得分:2)
尝试插入数据失败可能会导致死元组。例如:
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)
这也适用于因回滚而中止的插入。