Track statement entry timestamp in contrib/pg_stat_statements
Alexander Korotkov <akorotkov@postgresql.org>
Track statement entry timestamp in contrib/pg_stat_statements This patch adds 'stats_since' and 'minmax_stats_since' columns to the pg_stat_statements view and pg_stat_statements() function. The new min/max reset mode for the pg_stat_stetments_reset() function is controlled by the parameter minmax_only. 'stat_since' column is populated with the current timestamp when a new statement is added to the pg_stat_statements hashtable. It provides clean information about statistics collection time intervals for each statement. Besides it can be used by sampling solutions to detect situations when a statement was evicted and stored again between samples. Such a sampling solution could derive any pg_stat_statements statistic values for an interval between two samples with the exception of all min/max statistics. To address this issue this patch adds the ability to reset min/max statistics independently of the statement reset using the new minmax_only parameter of the pg_stat_statements_reset(userid oid, dbid oid, queryid bigint, minmax_only boolean) function. The timestamp of such reset is stored in the minmax_stats_since field for each statement. pg_stat_statements_reset() function now returns the timestamp of a reset as the result. Discussion: https://postgr.es/m/flat/72e80e7b160a6eb189df9ef6f068cce3765d37f8.camel%40moonset.ru Author: Andrei Zubkov Reviewed-by: Julien Rouhaud, Hayato Kuroda, Yuki Seino, Chengxi Sun Reviewed-by: Anton Melnikov, Darren Rush, Michael Paquier, Sergei Kornilov Reviewed-by: Alena Rybakina, Andrei Lepikhov
Files
| Path | Change | +/− |
|---|---|---|
| contrib/pg_stat_statements/expected/entry_timestamp.out | added | +159 −0 |
| contrib/pg_stat_statements/expected/oldextversions.out | modified | +65 −51 |
| contrib/pg_stat_statements/Makefile | modified | +1 −1 |
| contrib/pg_stat_statements/meson.build | modified | +1 −0 |
| contrib/pg_stat_statements/pg_stat_statements--1.10--1.11.sql | modified | +17 −6 |
| contrib/pg_stat_statements/pg_stat_statements.c | modified | +91 −28 |
| contrib/pg_stat_statements/sql/entry_timestamp.sql | added | +114 −0 |
| contrib/pg_stat_statements/sql/oldextversions.sql | modified | +3 −1 |
| doc/src/sgml/pgstatstatements.sgml | modified | +60 −9 |
Documentation touched
Discussion
Cited messages not in the archive:
flat/72e80e7b160a6eb189df9ef6f068cce3765d37f8.camel@moonset.ru