Re: Enable pg_stat_statements extension for limited statements only

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sayyid Ali Sajjad Rizavi <sasrizavi(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Enable pg_stat_statements extension for limited statements only
Date: 2022-11-30 18:15:04
Message-ID: 1434937.1669832104@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Sayyid Ali Sajjad Rizavi <sasrizavi(at)gmail(dot)com> writes:
> Hi, I'd like to propose a change and get advice if I should work on it.
> The extension pg_stat_statements is very helpful, but the downside is that
> it will take up too much disk space when storing query stats if it's
> enabled for all statements like SELECT, INSERT, UPDATE, DELETE.

It will only take up a lot of disk space if you let it, by setting
the pg_stat_statements.max parameter too high.

> For example, deletes do not happen too frequently; so I'd like to be able
> to enable pg_stat_statements only for the DELETE statement, maybe using
> some flags.

I'm a little skeptical of the value of that. Why would you want stats
only for infrequent statements?

I'm not denying that there might be usefulness in filtering what
pg_stat_statements will track, but it's not clear to me that
this particular proposal will be useful to many people.

I wonder whether there would be more use in filters expressed
as regular expressions to match against the statement text.
That would allow, for example, tracking statements that mention
a particular table as well as statements with a particular
head keyword. I could see usefulness in both a positive filter
(must match this to get tracked) and a negative one (must not
match this to get tracked).

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Verite 2022-11-30 18:22:42 Re: Tests for psql \g and \o
Previous Message Alvaro Herrera 2022-11-30 18:12:01 Re: generic plans and "initial" pruning