Re[2]: [PATCH] Add last_executed timestamp to pg_stat_statements

From: "Pavlo Golub" <pavlo(dot)golub(at)cybertec(dot)at>
To: "Sami Imseih" <samimseih(at)gmail(dot)com>
Cc: "Christoph Berg" <myon(at)debian(dot)org>, "Bertrand Drouvot" <bertranddrouvot(dot)pg(at)gmail(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re[2]: [PATCH] Add last_executed timestamp to pg_stat_statements
Date: 2026-03-30 16:42:29
Message-ID: em1b26b621-2e8b-4b29-a4ce-b75ee5f1ab1f@cybertec.at
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
>Here is something I was experimenting with today. I ran 2
>benchmarks; one on HEAD and one with GetCurrentTimestamp()
>added when we are accumulating stats.
>
>"""
> /* Increment the counts, except when jstate is not NULL */
> if (!jstate)
> {
> Assert(kind == PGSS_PLAN || kind == PGSS_EXEC);
>
> GetCurrentTimestamp();
>"""
>
>The benchmak script is a series of "SELECT;"
>
># select_tx.sql
>"""
>begin;
>select;
>select;
>select;
>select;
>select;
>select;
>select;
>select;
>select;
>select;
>select;
>select;
>select;
>select;
>select;
>end;
>"""
>
>The benchmark was on my Ubuntu on EC2 c5a.12xlarge,
>with default pg_stat_statements settings ( no plan tracking
>and top tracking only ).
>
>pgbench command:
>```
>pgbench -c48 -j16 -P1 -f select_tx.sql -T120
>```
>
>Results for 3 runs
>
>## HEAD
>tps = 29351.794589 (without initial connection time)
>tps = 29470.287111 (without initial connection time)
>tps = 29902.245458 (without initial connection time)
>
>## with GetCurrentTimestamp()
>tps = 28569.471891 (without initial connection time)
>tps = 28013.051778 (without initial connection time)
>tps = 28518.468843 (without initial connection time)
>
>I see around 4-5% performance degradation.

Yeah, I can confirm. I have the same degradation on my local
environment.

Thanks for pointing this out!

I sent a new patch with a new column `last_execution_start`. I hope it
could make it before freeze. :)

https://www.postgresql.org/message-id/em5619eed4-8913-4ee8-a3cd-9f7101b06b6d%40cybertec.at

Best regardsz

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2026-03-30 17:00:01 Re: remove bits* types
Previous Message Melanie Plageman 2026-03-30 16:41:09 Re: remove bits* types