postgresql/contrib/pg_stat_statements/sql
Alexander Korotkov dc9f8a7983 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
2023-11-27 02:52:17 +02:00
..
cleanup.sql Refactor tests of pg_stat_statements for planning, utility and level tracking 2023-02-20 09:28:29 +09:00
cursors.sql Add NOT NULL checking of pg_stat_statements_reset() in tests 2023-11-27 02:52:17 +02:00
dml.sql Add NOT NULL checking of pg_stat_statements_reset() in tests 2023-11-27 02:52:17 +02:00
entry_timestamp.sql Track statement entry timestamp in contrib/pg_stat_statements 2023-11-27 02:52:17 +02:00
level_tracking.sql Add NOT NULL checking of pg_stat_statements_reset() in tests 2023-11-27 02:52:17 +02:00
oldextversions.sql Track statement entry timestamp in contrib/pg_stat_statements 2023-11-27 02:52:17 +02:00
planning.sql Add NOT NULL checking of pg_stat_statements_reset() in tests 2023-11-27 02:52:17 +02:00
select.sql Add NOT NULL checking of pg_stat_statements_reset() in tests 2023-11-27 02:52:17 +02:00
user_activity.sql Add NOT NULL checking of pg_stat_statements_reset() in tests 2023-11-27 02:52:17 +02:00
utility.sql Add NOT NULL checking of pg_stat_statements_reset() in tests 2023-11-27 02:52:17 +02:00
wal.sql Add NOT NULL checking of pg_stat_statements_reset() in tests 2023-11-27 02:52:17 +02:00