Adding percentile metrics to pg_stat_statements module - Mailing list pgsql-hackers

From Igor Calabria
Subject Adding percentile metrics to pg_stat_statements module
Date
Msg-id CA+r4MrRSiHzXSQj0E8XyLgMYSbusiBQNADFjsO-sQgmGxXwMoQ@mail.gmail.com
Whole thread Raw
Responses Re: Adding percentile metrics to pg_stat_statements module  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: Adding percentile metrics to pg_stat_statements module  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
List pgsql-hackers
Hi everyone,

I was taking a look at pg_stat_statements module and noticed that it does not collect any percentile metrics. I believe that It would be really handy to have those available and I'd love to contribute with this feature.

The basic idea is to accumulate the the query execution times using an approximation structure like q-digest or t-digest and add those results to the pg_stat_statements table as fixed columns. Something like this

p90_time:
p95_time:
p99_time:
p70_time:
...

Another solution is to persist de digest structure in a binary column and use a function to extract the desired quantile ilke this SELECT approx_quantile(digest_times, 0.99) FROM pg_stat_statements

What do you guys think?
Cheers,

pgsql-hackers by date:

Previous
From: Andrzej Barszcz
Date:
Subject: Re: function calls optimization
Next
From: Andres Freund
Date:
Subject: Re: function calls optimization