Re: pg_stat_all_tables data isnt accurate

Поиск
Список
Период
Сортировка
От Nikolay Samokhvalov
Тема Re: pg_stat_all_tables data isnt accurate
Дата
Msg-id CANNMO+KPFFa8FEAWY7Dq5Phw_zPy+_Y2L2ebj7cxR6WgCnPK5A@mail.gmail.com
обсуждение исходный текст
Ответ на pg_stat_all_tables data isnt accurate  (Mariel Cherkassky <mariel.cherkassky@gmail.com>)
Список pgsql-admin
Hello Mariel,

On Mon, Dec 3, 2018 at 8:50 AM Mariel Cherkassky <mariel.cherkassky@gmail.com> wrote:
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=# 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)


These counters reflect what is going on "under hood" -- physically, job was done, tuples were inserted, but then just marked as dead. So n_tup_ins has absolutely correct value here.


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. 


"When using the statistics to monitor collected data, it is important to realize that the information does not update instantaneously. Each individual server process transmits new statistical counts to the collector just before going idle; so a query or transaction still in progress does not affect the displayed totals. Also, the collector itself emits a new report at most once per PGSTAT_STAT_INTERVAL milliseconds (500 ms unless altered while building the server). So the displayed information lags behind actual activity. However, current-query information collected by track_activities is always up-to-date."

Nik
 

В списке pgsql-admin по дате отправления:

Предыдущее
От: Mariel Cherkassky
Дата:
Сообщение: pg_stat_all_tables data isnt accurate
Следующее
От: AYahorau@ibagroup.eu
Дата:
Сообщение: Re: pg_basebackup fails: could not receive data from WAL stream: serverclosed the connection unexpectedly