[PATCH] Tracking statements entry timestamp in pg_stat_statements

From: Andrei Zubkov <zubkov(at)moonset(dot)ru>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: [PATCH] Tracking statements entry timestamp in pg_stat_statements
Date: 2021-03-22 09:07:48
Message-ID: 72e80e7b160a6eb189df9ef6f068cce3765d37f8.camel@moonset.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

This is a proposal for a new feature in pg_stat_statements extension.

As a statistical extension providing counters pg_stat_statements
extension is a target for various sampling solutions. All of them
interested in calculation of statement statistics increments between
two samples. But we face a problem here - observing one statement with
its statistics right now we can't be sure that statistics increment for
this statement is continuous from previous sample. This statement could
be deallocated after previous sample and come back soon. Also it could
happen that statement executions after that increased statistics to
above the values we observed in previous sample making it impossible to
detect deallocation on statement level.
My proposition here is to store statement entry timestamp. In this case
any sampling solution in case of returning statement will easily detect
it by changed timestamp value. And for every statement we will know
exact time interval for its statistics.

Attachment Content-Type Size
pg_stat_statements_ts_patch_2021_0322.patch text/x-patch 8.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2021-03-22 09:10:11 Re: WIP: BRIN multi-range indexes
Previous Message Andrei Zubkov 2021-03-22 09:06:15 Re: [PATCH] pg_stat_statements dealloc field ignores manual deallocation