Re: [PATCH] Tracking statements entry timestamp in pg_stat_statements

From: "Anton A(dot) Melnikov" <aamelnikov(at)inbox(dot)ru>
To: Andrei Zubkov <zubkov(at)moonset(dot)ru>, Julien Rouhaud <rjuju123(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] Tracking statements entry timestamp in pg_stat_statements
Date: 2022-02-08 07:47:18
Message-ID: 30a0cb8c-4f6c-8762-292a-a60ddb9c1710@inbox.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello!

On 26.01.2022 16:43, Andrei Zubkov wrote:

>>
>> If you're worried about some external table having a NOT NULL
>> constraint for
>> those fields, how about returning NaN instead? That's a valid value
>> for a
>> double precision data type.
>
> I don't know for sure what we can expect to be wrong here. My opinion
> is to use NULLs, as they seems more suitable here. But this can be done
> only if we are not expecting significant side effects.

Let me suggest for your consideration an additional reset request flag
that can be used to synchronize reset in a way similar to interrupt
handling.
External reset can set this flag immediately. Then pg_stat_statements
will wait for the moment when the required query hits into the
statistics and only at this moment really reset the aux statistics,
write a new timestamp and clear the flag. At the time of real reset,
total_time will be determined, and pg_stat_statements can immediately
initialize min and max correctly.
From reset to the next query execution the aux view will give old
correct values so neither NaNs nor NULLs will be required.
Also we can put the value of reset request flag into the aux view to
give feedback to the external application that reset was requested.

With best regards,
--
Anton A. Melnikov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2022-02-08 07:47:47 Re: [BUG]Update Toast data failure in logical replication
Previous Message Fujii Masao 2022-02-08 06:34:21 Re: [PATCH] Add min() and max() aggregate functions for xid8