| From: | Sami Imseih <samimseih(at)gmail(dot)com> |
|---|---|
| To: | Pavlo Golub <pavlo(dot)golub(at)cybertec(dot)at> |
| Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] pg_stat_statements: add last_execution_start column |
| Date: | 2026-03-30 21:33:05 |
| Message-ID: | CAA5RZ0tMEN_wo=WCT6erJ9t6d62Rh+K4w+8ofpjPrBS+-18WxQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
It would be really great to get this field in, but I think the current
implementation still suffers from the same issue that is mentioned
here [1]. We cannot rely on GetCurrentStatementStartTimestamp()
in-line because ExecutorEnd is deferred to the next execution in the
case of extended query protocol. I think we need to add it to track the
start timestamp in queryDesc. What do you think?
```
select pg_stat_statements_reset();
BEGIN;
select now() as now, clock_timestamp() as clock_timestamp,
pg_sleep($1) \bind 10 \g
\! sleep 10
SELECT now() as now, clock_timestamp() as clock_timestamp, $1 \bind 1 \g
END;
select last_execution_start, total_exec_time, substr(query, 1, 150) as
query from pg_stat_statements;
```
Notice how the last_execution_start reflects when the
"SELECT now() as now, clock_timestamp() as clock_timestamp, $1 " runs
--
Sami
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jacob Champion | 2026-03-30 21:33:29 | Re: Make PGOAUTHCAFILE in libpq-oauth work out of debug mode |
| Previous Message | Zsolt Parragi | 2026-03-30 21:32:22 | Re: Patch: dumping tables data in multiple chunks in pg_dump |