public inbox for [email protected]  
help / color / mirror / Atom feed
From: Sami Imseih <[email protected]>
To: Pavlo Golub <[email protected]>
Cc: Christoph Berg <[email protected]>
Cc: Bertrand Drouvot <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: [PATCH] Add last_executed timestamp to pg_stat_statements
Date: Tue, 17 Feb 2026 17:59:12 -0600
Message-ID: <CAA5RZ0tiUbG5RNK-Es+=R9RGpUkCBeJ_WQA5GzpAD3QiDgS3MA@mail.gmail.com> (raw)
In-Reply-To: <CAK7ymc+Kr7i6p_6Hw_2hEg3xVRH8FYnnrEp0PHg+jeMvqH7mLg@mail.gmail.com>
References: <CAA5RZ0vMW+0_6FYtFEaN-NAnk1sT2ucCUDJe0-xKwZriROV--A@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<CAA5RZ0sxPWP2xm8fxhscE+cUqC2VSFi9UZ9882BdGZ0MbGQNUA@mail.gmail.com>
	<CAK7ymc+0z7pL-Jub_52JDCyByxK3iYG7KHmudhsjgzF4WGmY0Q@mail.gmail.com>
	<CAA5RZ0sUjsmCNTRHmpOpYNLJ0vbAMc00aJGtCeh6k3YKNw0LQQ@mail.gmail.com>
	<CAK7ymc+Kr7i6p_6Hw_2hEg3xVRH8FYnnrEp0PHg+jeMvqH7mLg@mail.gmail.com>

> > I am not sure if this benchmark is enough to build confidence in this approach.
> > Workloads with nested queries and tack. 'all' are now paying an even heavier
> > cost.
>
> I would love to see and test sql that will reveal the bigger overhead.
> Do you have something specific on your mind? I'd love to share
> results, we can use them later considering further updates to pgss.

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.


--
Sami Imseih
Amazon Web Services (AWS)






view thread (8+ 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: [PATCH] Add last_executed timestamp to pg_stat_statements
  In-Reply-To: <CAA5RZ0tiUbG5RNK-Es+=R9RGpUkCBeJ_WQA5GzpAD3QiDgS3MA@mail.gmail.com>

* 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