public inbox for [email protected]
help / color / mirror / Atom feedFrom: Pavlo Golub <[email protected]>
To: Christoph Berg <[email protected]>
Cc: Sami Imseih <[email protected]>
Cc: Bertrand Drouvot <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re[2]: [PATCH] Add last_executed timestamp to pg_stat_statements
Date: Fri, 06 Feb 2026 11:19:26 +0000
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <CAK7ymc+FxoVswo1ok_xDW-xPG-ZEZ8SAqCUkJ7WF04=0aQDvVQ@mail.gmail.com>
<CAA5RZ0uyvnNuHRj=73jZhocnLxE07oM-AeSLS=FUuuZ_hy7fKA@mail.gmail.com>
<[email protected]>
<CAA5RZ0u6qdcLoWJJz5mUB_VYZqT__U-HJJ5_ioYO7XGsUfXfpw@mail.gmail.com>
<[email protected]>
<CAA5RZ0tH_+3JGMCktkp8EMyvKaRAJf-xRh+y_UoZ8azvuUEAYQ@mail.gmail.com>
<[email protected]>
<CAK7ymc+E00zKC9Da+BK2se=O2RiOUkdW5dz4iAynD1Vj=Pwexg@mail.gmail.com>
<CAA5RZ0u_jjiLc_w4nksdVazvvqtE17C1nM=sKf9fy5x02orfsg@mail.gmail.com>
<[email protected]>
<[email protected]>
>
>I still believe that storing execution start time is the wrong thing
>to do as it will miss all long-running statements. Consider this
>timeline:
>
>09:55 get all stats changed since 09:50
> -> doesn't see the statement because it hasn't started yet
>09:57 start long-running statement
>10:00 get all stats changed since 09:55
> -> doesn't see the statement because it's still running
>10:02 long-running statement terminates, storing 09:57 as timestamp
>10:05 get all stats changed since 10:00
> -> doesn't see the statement because it's too old
>
Thanks for sharing this. I spent a sleepless night and it seems I found
the solution for the issue.
If we do
WHERE last_execution_start + max_exec_time * INTERVAL '1 ms' > NOW() -
polling_interval
we will grab all long-running statements. The worst thing that might
happen, if some query
has significant run time deviation, then we could grab it several times.
But again this is far
better than re-fetching thousands of rows every time.
For short queries it will just work as expected. "Issues" might be only
with long queries with
a high deviation longer than polling interval. But fetching one or two
rows once in a while is not
a problem.
view thread (3+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: Re[2]: [PATCH] Add last_executed timestamp to pg_stat_statements
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox