pg_stat_statements: Add gc_count and query_file_size to pgss_info

From: Lukas Fittl <lukas(at)fittl(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: pg_stat_statements: Add gc_count and query_file_size to pgss_info
Date: 2026-02-28 23:46:39
Message-ID: CAP53PkzYZ8YxH0o+Garw9fWdFRoEtmQKT09-q=2RVMW8uVS5Nw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Over the last weeks we've been fighting again with pg_stat_statements
issues, specifically with the issue of having too many unique entries,
and the corresponding problem of large query text files and LWLock
wait events related to pg_stat_statements.

I think we can improve debugging for such situations by adding two
more columns to pg_stat_statements_info that expose information
already tracked:

1) "gc_count", showing when the pg_stat_statements query garbage
collection cycles occur (which can correlate with
LWLock:pg_stat_statements)

2) "query_file_size" which tells us the extent of the query text file,
so we can fine-tune when we query the texts from pg_stat_statements in
monitoring scripts (i.e. query it less frequently if the query text
file is very large).

I've had a patch to improve this prepared for a previous cycle, but
wasn't sure it was still needed because of the discussion re: keeping
query texts in shared memory. But since it looks like that won't
change for 19 (though I'm hoping to contribute more to improving that
in the PG 20 cycle), see attached for consideration.

Thanks,
Lukas

--
Lukas Fittl

Attachment Content-Type Size
v1-0001-pg_stat_statements-Add-gc_count-and-query_file_si.patch application/octet-stream 9.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Lukas Fittl 2026-02-28 23:58:34 pg_buffercache: Add per-relation summary stats
Previous Message Alena Rybakina 2026-02-28 22:20:00 Re: Vacuum statistics