Re: Fix pg_stat_statements losing normalized query text after reset

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, chong(dot)peng(at)enmotech(dot)com, Lukas Fittl <lukas(at)fittl(dot)com>
Subject: Re: Fix pg_stat_statements losing normalized query text after reset
Date: 2026-08-31 07:29:42
Message-ID: apUtZm9WKscIjkat@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Aug 31, 2026 at 03:07:47PM +0800, Chao Li wrote:
> Based on this understanding, I made a fix that resets existing
> entries back to the sticky state rather than deleting them. This
> preserves the normalized query text for cached prepared
> statements. If a query with the same query ID is parsed again later,
> the sticky entry is updated with the newly normalized query
> text. I’m not very familiar with the history and design
> considerations around pg_stat_statements_reset(), so I don’t have
> full confidence that retaining the entries is the intended approach,
> so comments are welcome.

I doubt that this is worth complicating the code of PGSS for.
pg_stat_statements_reset() is used, sure, but the case of a prepared
statement reusing a non-normalized query post-reset feels too edgy for
me to care about. Let's keep the code simpler.
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Guo 2026-08-31 07:32:02 Re: remove_useless_joins vs. bug #19560
Previous Message Michael Paquier 2026-08-31 07:26:06 Re: Use pg_neg_s*_overflow() for open-coded negation overflow checks