pg_stat_all_tables data isnt accurate - Mailing list pgsql-admin

From Mariel Cherkassky
Subject pg_stat_all_tables data isnt accurate
Date
Msg-id CA+t6e1kCqAOUaVQrBGgb=iYaKrW4d0qwu-an_Zaov57Pb54+SQ@mail.gmail.com
Whole thread Raw
Responses Re: pg_stat_all_tables data isnt accurate  (Nikolay Samokhvalov <samokhvalov@gmail.com>)
List pgsql-admin
Hi,
We are trying to use the info in pg_Stat_all_tables to debug our applcation(see how much inserts/updates/deletes since the last reset). However we found some scenarios where the data in the view isnt accurate : 

1)When you preform a rollback all the inserts/updates/deletes you did are added to the n_tup_ins/upd/del column : 

postgres=# \d pgstat.pg_stat_all_tables;^C
postgres=# create table test(a int);

postgres=# select relname, n_live_tup,n_tup_ins,n_tup_del,n_tup_upd from pg_Stat_all_tables where relname='test';
 relname | n_live_tup | n_tup_ins | n_tup_del | n_tup_upd
---------+------------+-----------+-----------+-----------
 test    |          0 |         0 |         0 |         0
(1 row)


postgres=# start transaction
postgres-# ;
START TRANSACTION
postgres=# insert into test values(5);
INSERT 0 1
postgres=# insert into test values(6);
INSERT 0 1
postgres=# insert into test values(7);
INSERT 0 1
postgres=# rollback;
ROLLBACK
postgres=# select relname, n_live_tup,n_tup_ins,n_tup_del,n_tup_upd from pg_Stat_all_tables where relname='test';
 relname | n_live_tup | n_tup_ins | n_tup_del | n_tup_upd
---------+------------+-----------+-----------+-----------
 test    |          0 |         3 |         0 |         0
(1 row)


2)sometimes the n_tup_ins isnt accurate and it takes some time until it is updated. Does someone has an explanation for it ? During that time analyze isnt running so it seems might be something else. 



pgsql-admin by date:

Previous
From: Shreeyansh Dba
Date:
Subject: Re: pg_basebackup fails: could not receive data from WAL stream:server closed the connection unexpectedly
Next
From: Nikolay Samokhvalov
Date:
Subject: Re: pg_stat_all_tables data isnt accurate