Re: Add min and max execute statement time in pg_stat_statement - Mailing list pgsql-hackers

From Ants Aasma
Subject Re: Add min and max execute statement time in pg_stat_statement
Date
Msg-id CA+CSw_vL8ufYoPyeVTBCiKPybY_K5HStOrYu+Kp1XRDmHpKC8g@mail.gmail.com
Whole thread Raw
In response to Re: Add min and max execute statement time in pg_stat_statement  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Responses Re: Add min and max execute statement time in pg_stat_statement  (Gavin Flower <GavinFlower@archidevsys.co.nz>)
Re: Add min and max execute statement time in pg_stat_statement  (Gavin Flower <GavinFlower@archidevsys.co.nz>)
List pgsql-hackers
On Tue, Oct 22, 2013 at 1:09 AM, Alvaro Herrera
<alvherre@2ndquadrant.com> wrote:
> Gavin Flower wrote:
>
>> One way it could be done, but even this would consume far too much
>> storage and processing power (hence totally impractical), would be
>> to 'simply' store a counter for each value found and increment it
>> for each occurence...
>
> An histogram?  Sounds like a huge lot of code complexity to me.  Not
> sure the gain is enough.

I have a proof of concept patch somewhere that does exactly this. I
used logarithmic bin widths. With 8 log10 bins you can tell the
fraction of queries running at each order of magnitude from less than
1ms to more than 1000s. Or with 31 bins you can cover factor of 2
increments from 100us to over 27h. And the code is almost trivial,
just take a log of the duration and calculate the bin number from that
and increment the value in the corresponding bin.

Regards,
Ants Aasma
--
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt
Web: http://www.postgresql-support.de



pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Add min and max execute statement time in pg_stat_statement
Next
From: Gavin Flower
Date:
Subject: Re: Add min and max execute statement time in pg_stat_statement