Re: Add min and max execute statement time in pg_stat_statement

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Arne Scheffer <arne(dot)scheffer(at)uni-muenster(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, KONDO Mitsumasa <kondo(dot)mitsumasa(at)lab(dot)ntt(dot)co(dot)jp>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Rajeev rastogi <rajeev(dot)rastogi(at)huawei(dot)com>, Mitsumasa KONDO <kondo(dot)mitsumasa(at)gmail(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>
Subject: Re: Add min and max execute statement time in pg_stat_statement
Date: 2015-01-20 22:30:53
Message-ID: 54BED71D.4050302@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 01/20/2015 01:26 PM, Arne Scheffer wrote:
> Interesting patch.
> I did a quick review looking only into the patch file.
>
> The "sum of variances" variable contains
> the "sum of squared differences" instead, I think.

Umm, no. It's not.

e->counters.sum_var_time +=
(total_time - old_mean) * (total_time - e->counters.mean_time);

This is not a square that's being added. old_mean is not the same as
e->counters.mean_time.

Since the variance is this value divided by (n - 1), AIUI, I think "sum
of variances" isn't a bad description. I'm open to alternative suggestions.

>
> And a very minor aspect:
> The term "standard deviation" in your code stands for
> (corrected) sample standard deviation, I think,
> because you devide by n-1 instead of n to keep the
> estimator unbiased.
> How about mentioning the prefix "sample"
> to indicate this beiing the estimator?

I don't understand. I'm following pretty exactly the calculations stated
at <http://www.johndcook.com/blog/standard_deviation/>

I'm not a statistician. Perhaps others who are more literate in
statistics can comment on this paragraph.

>
> And I'm sure I'm missing C specifics (again)
> (or it's the reduced patch file scope),
> but you introduce sqrtd, but sqrt is called?

Good catch. Will fix.

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2015-01-20 22:37:20 Re: PATCH: decreasing memory needlessly consumed by array_agg
Previous Message Peter Geoghegan 2015-01-20 22:04:58 Re: B-Tree support function number 3 (strxfrm() optimization)