Dead Tuples without updates/deletes

后端 未结 1 1840
太阳男子
太阳男子 2021-01-19 10:49

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 ea

1条回答
  •  执笔经年
    2021-01-19 11:45

    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.

    0 讨论(0)
提交回复
热议问题