From:
Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
To:
Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc:
PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, David Fetter <david(at)fetter(dot)org>
Subject:
Re: wip: functions median and percentile
Date:
2010-09-20 03:47:09
Message-ID:
AANLkTi=P1-S7zF4ed544LrE8-L+C2qa9T6pSd8nU5h_a@mail.gmail.com (view raw or flat )
Thread:
2010-08-19 10:59:33 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-08-19 14:50:23 from Greg Stark <gsstark(at)mit(dot)edu>
2010-08-19 15:33:13 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-08-19 16:49:45 from Robert Haas <robertmhaas(at)gmail(dot)com>
2010-08-19 17:03:20 from David Fetter <david(at)fetter(dot)org>
2010-08-19 17:12:12 from "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
2010-08-19 17:14:58 from David Fetter <david(at)fetter(dot)org>
2010-08-19 17:25:36 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-08-19 17:47:59 from David Fetter <david(at)fetter(dot)org>
2010-08-19 18:17:42 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-08-19 17:41:57 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-08-19 18:17:28 from "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
2010-08-19 17:38:14 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-09-20 03:47:09 from Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
2010-09-20 05:11:02 from David Fetter <david(at)fetter(dot)org>
2010-09-20 06:22:29 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-09-21 20:28:15 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-09-21 20:44:16 from Robert Haas <robertmhaas(at)gmail(dot)com>
2010-09-21 21:03:31 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-09-22 02:21:01 from Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
2010-09-22 04:36:24 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-09-22 03:06:51 from Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
2010-09-22 04:44:58 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-09-23 09:35:47 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-09-23 17:45:36 from Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
2010-09-23 18:27:38 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-09-23 18:48:47 from David Fetter <david(at)fetter(dot)org>
2010-09-23 18:56:53 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-09-26 10:39:21 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-10-01 08:17:19 from Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
2010-10-01 08:46:45 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-10-01 13:05:43 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-10-01 13:19:57 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-10-01 14:11:08 from Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
2010-10-01 14:43:47 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-10-01 15:00:35 from Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
2010-10-01 15:08:00 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-10-01 15:15:03 from "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
2010-10-01 15:35:03 from Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
2010-10-01 15:16:03 from Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
2010-10-01 15:22:46 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-10-01 15:32:03 from Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
2010-10-01 17:37:03 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-10-01 19:17:08 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-10-03 14:06:25 from Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
2010-10-03 15:49:37 from Greg Stark <gsstark(at)mit(dot)edu>
2010-10-04 06:36:48 from Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
2010-10-04 06:58:44 from Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
2010-10-04 16:14:06 from Greg Stark <gsstark(at)mit(dot)edu>
2010-10-04 17:22:39 from Robert Haas <robertmhaas(at)gmail(dot)com>
2010-10-04 19:20:28 from Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
2010-10-05 06:04:31 from Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
2010-10-05 08:47:52 from Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
2010-10-05 12:14:24 from Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
2010-10-05 13:08:59 from Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
2010-10-10 21:16:59 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-10-11 06:58:53 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-10-11 09:35:13 from Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
2010-10-11 09:55:16 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-10-11 10:33:11 from Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
2010-10-11 14:03:40 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-10-11 15:30:46 from Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
2010-10-11 15:44:08 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-10-11 17:34:51 from Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
2010-10-11 17:37:11 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-10-11 17:42:10 from Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
2010-10-11 17:48:12 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-10-11 17:55:32 from Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
2010-10-11 18:05:11 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-10-11 18:23:25 from Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
2010-10-11 10:33:12 from Robert Haas <robertmhaas(at)gmail(dot)com>
2010-10-11 14:08:53 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-10-11 14:29:38 from Robert Haas <robertmhaas(at)gmail(dot)com>
2010-10-11 18:27:13 from Greg Stark <gsstark(at)mit(dot)edu>
2010-10-11 18:30:39 from Josh Berkus <josh(at)agliodbs(dot)com>
2010-10-11 18:46:47 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-10-12 03:08:32 from Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
2010-10-12 08:44:20 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-10-13 10:36:59 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-10-13 10:48:17 from Peter Eisentraut <peter_e(at)gmx(dot)net>
2010-10-13 10:51:51 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-10-13 10:56:06 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-10-14 00:54:42 from Robert Haas <robertmhaas(at)gmail(dot)com>
2010-10-14 02:37:37 from Greg Stark <gsstark(at)mit(dot)edu>
2010-10-14 12:17:54 from Robert Haas <robertmhaas(at)gmail(dot)com>
2010-10-14 04:53:57 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-10-03 17:31:18 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-10-01 14:44:44 from Robert Haas <robertmhaas(at)gmail(dot)com>
2010-09-23 13:22:39 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
2010-09-23 13:25:32 from Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Lists:
pgsql-hackers pgsql-rrreviewers
2010/8/19 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>:
> Hello
>
> I am sending a prototype implementation of functions median and
> percentile. This implementation is very simple and I moved it to
> contrib for this moment - it is more easy maintainable. Later I'll
> move it to core.
I've reviewed this patch.
* The patch can apply cleanly and make doesn't print any errors nor
warnings. But it doesn't touch contrib/Makefile so I had to make by
changing dir to contrib/median.
* Cosmetic coding style should be more appropriate, including trailing
white spaces and indentation positions.
* Since these two aggregates use tuplesort inside it, there're
possible risk to cause out of memory in normal use case. I don't think
this fact is critical, but at least some notation should be referred
in docs.
* It doesn't contain any document nor regression tests.
* They should be callable in window function context; for example
contrib_regression=# select median(a) over (order by a) from t1;
ERROR: invalid tuplesort state
or at least user-friend message should be printed.
* The returned type is controversy. median(int) returns float8 as the
patch intended, but avg(int) returns numeric. AFAIK only avg(float8)
returns float8.
* percentile() is more problematic; first, the second argument for the
aggregate takes N of "N%ile" as int, like 50 if you want 50%ile, but
it doesn't care about negative values or more than 100. In addition,
the second argument is taken at the first non-NULL value of the first
argument, but the second argument is semantically constant. For
example, for (1.. 10) value of a in table t1,
contrib_regression=# select percentile(a, a * 10 order by a) from t1;
percentile
------------
1
(1 row)
contrib_regression=# select percentile(a, a * 10 order by a desc) from t1;
percentile
------------
10
(1 row)
and if the argument comes from the subquery which doesn't contain
ORDER BY clause, you cannot predict the result.
That's all of my quick review up to now.
Regards,
--
Hitoshi Harada
In response to
Responses
pgsql-hackers by date
Next :From: Bruce MomjianDate: 2010-09-20 03:47:35
Subject : Re: So where did that $Id$ come from?
Previous :From : Josh BerkusDate : 2010-09-20 02:31:52
Subject : Re: Configuring synchronous replication
pgsql-rrreviewers by date
Next :From: David FetterDate: 2010-09-20 05:11:02
Subject : Re: [HACKERS] wip: functions median and percentile
Previous :From : David FetterDate : 2010-09-17 16:53:47
Subject : client authentication hook