Re: Improve pg_stat_statements scalability

From: Julien Rouhaud <rjuju123(at)gmail(dot)com>
To: Lukas Fittl <lukas(at)fittl(dot)com>
Cc: Sami Imseih <samimseih(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improve pg_stat_statements scalability
Date: 2026-05-23 23:25:57
Message-ID: ahI3hfji3FI6fY5X@jrouhaud
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Fri, May 22, 2026 at 06:15:00PM -0700, Lukas Fittl wrote:
>
> For archive's sake and others reading along, we had a productive
> discussion about this today at PGConf.Dev.
>
> I've created a new wiki page combining the prior 2025 discussion, and
> notes from today:
>
> https://wiki.postgresql.org/wiki/Scalability_of_pg_stat_statements

Thanks a lot Lukas!

Just a small clarification, I wasn't asking for a way to remember the last time
a query was executed (although I think it's a very good thing to have), but
remembering the time each query text was saved.

In a reasonable system (that is a system where the number of entries doesn't
grow much more than pg_stat_statements.max, ie, you can actually use the
current version pg_stat_statements) you will likely get a lot of entries even
if you filter out the entries that didn't get executed in the last X minutes.
However, the vast majority of them should not be new queries. So if you
maintain an external system that snapshot pg_stat_statements once in a while
you only care about the (possibly) missing query texts, which should be a very
small fraction of all the records you otherwise need.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Sami Imseih 2026-05-24 01:29:26 Re: Improve pg_stat_statements scalability
Previous Message Aaryan Parik 2026-05-23 19:18:22 [PATCH] psql: Display SQLSTATE macro name in verbose error reports