Re: [HACKERS] wip: functions median and percentile

2010-10-14 Thread Greg Stark
On Wed, Oct 13, 2010 at 5:54 PM, Robert Haas robertmh...@gmail.com wrote: Or to put it more bluntly - what is the problem with planner and hash agg that all of these functions need to solve?  And why does it need a flag in pg_proc?  Why can't't we leave it to the individual functions to

Re: [HACKERS] wip: functions median and percentile

2010-10-14 Thread Robert Haas
On Wed, Oct 13, 2010 at 6:56 AM, Pavel Stehule pavel.steh...@gmail.com wrote: 2010/10/13 Pavel Stehule pavel.steh...@gmail.com: 2010/10/13 Peter Eisentraut pete...@gmx.net: On mån, 2010-10-11 at 20:46 +0200, Pavel Stehule wrote: The problem is in interface. The original patch did it, but I

Re: [HACKERS] wip: functions median and percentile

2010-10-14 Thread Pavel Stehule
2010/10/14 Robert Haas robertmh...@gmail.com: On Wed, Oct 13, 2010 at 6:56 AM, Pavel Stehule pavel.steh...@gmail.com wrote: 2010/10/13 Pavel Stehule pavel.steh...@gmail.com: 2010/10/13 Peter Eisentraut pete...@gmx.net: On mån, 2010-10-11 at 20:46 +0200, Pavel Stehule wrote: The problem is

Re: [HACKERS] wip: functions median and percentile

2010-10-14 Thread Robert Haas
On Wed, Oct 13, 2010 at 10:37 PM, Greg Stark gsst...@mit.edu wrote: On Wed, Oct 13, 2010 at 5:54 PM, Robert Haas robertmh...@gmail.com wrote: Or to put it more bluntly - what is the problem with planner and hash agg that all of these functions need to solve?  And why does it need a flag in

Re: [HACKERS] wip: functions median and percentile

2010-10-13 Thread Pavel Stehule
Hello I am looking on SQL standard for some info about within group clause. This clause is necessary for functions: rank, dense_rank, cume_dist, percent_rank and percentile_disc and persentile_cont. These functions needs a clause WITHIN GROUP. If I understand, then these functions are not

Re: [HACKERS] wip: functions median and percentile

2010-10-13 Thread Peter Eisentraut
On mån, 2010-10-11 at 20:46 +0200, Pavel Stehule wrote: The problem is in interface. The original patch did it, but I removed it. We cannot to unsure immutability of some parameters now. How about you store the immutable parameter in the transition state and error out if it changes between

Re: [HACKERS] wip: functions median and percentile

2010-10-13 Thread Pavel Stehule
2010/10/13 Peter Eisentraut pete...@gmx.net: On mån, 2010-10-11 at 20:46 +0200, Pavel Stehule wrote: The problem is in interface. The original patch did it, but I removed it. We cannot to unsure immutability of some parameters now. How about you store the immutable parameter in the transition

Re: [HACKERS] wip: functions median and percentile

2010-10-13 Thread Pavel Stehule
2010/10/13 Pavel Stehule pavel.steh...@gmail.com: 2010/10/13 Peter Eisentraut pete...@gmx.net: On mån, 2010-10-11 at 20:46 +0200, Pavel Stehule wrote: The problem is in interface. The original patch did it, but I removed it. We cannot to unsure immutability of some parameters now. How about

Re: [HACKERS] wip: functions median and percentile

2010-10-12 Thread Pavel Stehule
2010/10/12 Hitoshi Harada umi.tan...@gmail.com: 2010/10/12 Pavel Stehule pavel.steh...@gmail.com: Hello 2010/10/11 Greg Stark gsst...@mit.edu: On Sun, Oct 10, 2010 at 2:16 PM, Tom Lane t...@sss.pgh.pa.us wrote: It was pointed out upthread that while median isn't presently in the standard,

Re: [HACKERS] wip: functions median and percentile

2010-10-11 Thread Pavel Stehule
2010/10/10 Tom Lane t...@sss.pgh.pa.us: Dean Rasheed dean.a.rash...@gmail.com writes: In the meantime, the attached variation of the patch fixes the temp file issue and will support all 3 cases. It gives OK performance for (1) and (2), and poor performance for (3). That could be viewed as a

Re: [HACKERS] wip: functions median and percentile

2010-10-11 Thread Dean Rasheed
On 10 October 2010 22:16, Tom Lane t...@sss.pgh.pa.us wrote: It was pointed out upthread that while median isn't presently in the standard, Oracle defines it in terms of percentile_cont(0.5) which *is* in the standard.  What I read in SQL:2008 is that percentile_cont is defined for all numeric

Re: [HACKERS] wip: functions median and percentile

2010-10-11 Thread Pavel Stehule
2010/10/11 Dean Rasheed dean.a.rash...@gmail.com: On 10 October 2010 22:16, Tom Lane t...@sss.pgh.pa.us wrote: It was pointed out upthread that while median isn't presently in the standard, Oracle defines it in terms of percentile_cont(0.5) which *is* in the standard.  What I read in SQL:2008

Re: [HACKERS] wip: functions median and percentile

2010-10-11 Thread Dean Rasheed
On 11 October 2010 10:55, Pavel Stehule pavel.steh...@gmail.com wrote: BTW, why has percentile been removed from this patch? As the more general, and SQL standard function, that would seem to be the more useful one to include. Upthread it was mentioned that there is already an ntile window

Re: [HACKERS] wip: functions median and percentile

2010-10-11 Thread Robert Haas
On Sun, Oct 10, 2010 at 5:16 PM, Tom Lane t...@sss.pgh.pa.us wrote: It was pointed out upthread that while median isn't presently in the standard, Oracle defines it in terms of percentile_cont(0.5) which *is* in the standard.  What I read in SQL:2008 is that percentile_cont is defined for all

Re: [HACKERS] wip: functions median and percentile

2010-10-11 Thread Tom Lane
Dean Rasheed dean.a.rash...@gmail.com writes: On 10 October 2010 22:16, Tom Lane t...@sss.pgh.pa.us wrote: BTW, as far as the implementation issues go, telling tuplesort that it can use gigabytes of memory no matter what seems quite unacceptable. Put this thing into a hash aggregation and

Re: [HACKERS] wip: functions median and percentile

2010-10-11 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: On Sun, Oct 10, 2010 at 5:16 PM, Tom Lane t...@sss.pgh.pa.us wrote: It was pointed out upthread that while median isn't presently in the standard, Oracle defines it in terms of percentile_cont(0.5) which *is* in the standard.  What I read in SQL:2008

Re: [HACKERS] wip: functions median and percentile

2010-10-11 Thread Robert Haas
On Mon, Oct 11, 2010 at 10:08 AM, Tom Lane t...@sss.pgh.pa.us wrote: Robert Haas robertmh...@gmail.com writes: On Sun, Oct 10, 2010 at 5:16 PM, Tom Lane t...@sss.pgh.pa.us wrote: It was pointed out upthread that while median isn't presently in the standard, Oracle defines it in terms of

Re: [HACKERS] wip: functions median and percentile

2010-10-11 Thread Dean Rasheed
On 11 October 2010 15:03, Tom Lane t...@sss.pgh.pa.us wrote: Dean Rasheed dean.a.rash...@gmail.com writes: On 10 October 2010 22:16, Tom Lane t...@sss.pgh.pa.us wrote: BTW, as far as the implementation issues go, telling tuplesort that it can use gigabytes of memory no matter what seems quite

Re: [HACKERS] wip: functions median and percentile

2010-10-11 Thread Tom Lane
Dean Rasheed dean.a.rash...@gmail.com writes: On 11 October 2010 15:03, Tom Lane t...@sss.pgh.pa.us wrote: Reflecting on it, I think it'd be best to allow an agg to provide an estimation function that'd be told the input data type and expected number of rows --- even on a per-aggregate basis,

Re: [HACKERS] wip: functions median and percentile

2010-10-11 Thread Dean Rasheed
On 11 October 2010 16:44, Tom Lane t...@sss.pgh.pa.us wrote: Dean Rasheed dean.a.rash...@gmail.com writes: On 11 October 2010 15:03, Tom Lane t...@sss.pgh.pa.us wrote: Reflecting on it, I think it'd be best to allow an agg to provide an estimation function that'd be told the input data type

Re: [HACKERS] wip: functions median and percentile

2010-10-11 Thread Tom Lane
Dean Rasheed dean.a.rash...@gmail.com writes: The estimate of 200 x 8K is below work_mem, so it uses a hash aggregate. In reality, each tuplesort allocates around 30K initially, so it very quickly uses over 1GB. A better estimate for the aggregate wouldn't improve this situation much. Sure it

Re: [HACKERS] wip: functions median and percentile

2010-10-11 Thread Dean Rasheed
On 11 October 2010 18:37, Tom Lane t...@sss.pgh.pa.us wrote: Dean Rasheed dean.a.rash...@gmail.com writes: The estimate of 200 x 8K is below work_mem, so it uses a hash aggregate. In reality, each tuplesort allocates around 30K initially, so it very quickly uses over 1GB. A better estimate for

Re: [HACKERS] wip: functions median and percentile

2010-10-11 Thread Tom Lane
Dean Rasheed dean.a.rash...@gmail.com writes: On 11 October 2010 18:37, Tom Lane t...@sss.pgh.pa.us wrote: Sure it would: an estimate of 30K would keep the planner from using hash aggregation. Not if work_mem was 10MB. And? If the memory requirement actually fits, you're in good shape.

Re: [HACKERS] wip: functions median and percentile

2010-10-11 Thread Dean Rasheed
On 11 October 2010 18:48, Tom Lane t...@sss.pgh.pa.us wrote: Dean Rasheed dean.a.rash...@gmail.com writes: On 11 October 2010 18:37, Tom Lane t...@sss.pgh.pa.us wrote: Sure it would: an estimate of 30K would keep the planner from using hash aggregation. Not if work_mem was 10MB. And?  If

Re: [HACKERS] wip: functions median and percentile

2010-10-11 Thread Tom Lane
Dean Rasheed dean.a.rash...@gmail.com writes: On 11 October 2010 18:48, Tom Lane t...@sss.pgh.pa.us wrote: And?  If the memory requirement actually fits, you're in good shape. Yeah but the actual memory requirement, if it uses a hash aggregate, is over 1GB, and could easily be much higher.

Re: [HACKERS] wip: functions median and percentile

2010-10-11 Thread Dean Rasheed
On 11 October 2010 19:05, Tom Lane t...@sss.pgh.pa.us wrote: Dean Rasheed dean.a.rash...@gmail.com writes: On 11 October 2010 18:48, Tom Lane t...@sss.pgh.pa.us wrote: And?  If the memory requirement actually fits, you're in good shape. Yeah but the actual memory requirement, if it uses a

Re: [HACKERS] wip: functions median and percentile

2010-10-11 Thread Greg Stark
On Sun, Oct 10, 2010 at 2:16 PM, Tom Lane t...@sss.pgh.pa.us wrote: It was pointed out upthread that while median isn't presently in the standard, Oracle defines it in terms of percentile_cont(0.5) which *is* in the standard. Uhmm, then why don't we implement that? We could provide median() as

Re: [HACKERS] wip: functions median and percentile

2010-10-11 Thread Josh Berkus
Uhmm, then why don't we implement that? We could provide median() as a short-cut but percentile_cont() doesn't sound much harder to implement than median() and more general. I could really use percentile_cont(0.9), actually, for query response-time analysis. --

Re: [HACKERS] wip: functions median and percentile

2010-10-11 Thread Pavel Stehule
Hello 2010/10/11 Greg Stark gsst...@mit.edu: On Sun, Oct 10, 2010 at 2:16 PM, Tom Lane t...@sss.pgh.pa.us wrote: It was pointed out upthread that while median isn't presently in the standard, Oracle defines it in terms of percentile_cont(0.5) which *is* in the standard. Uhmm, then why don't

Re: [HACKERS] wip: functions median and percentile

2010-10-11 Thread Hitoshi Harada
2010/10/12 Pavel Stehule pavel.steh...@gmail.com: Hello 2010/10/11 Greg Stark gsst...@mit.edu: On Sun, Oct 10, 2010 at 2:16 PM, Tom Lane t...@sss.pgh.pa.us wrote: It was pointed out upthread that while median isn't presently in the standard, Oracle defines it in terms of percentile_cont(0.5)

Re: [HACKERS] wip: functions median and percentile

2010-10-10 Thread Tom Lane
Dean Rasheed dean.a.rash...@gmail.com writes: In the meantime, the attached variation of the patch fixes the temp file issue and will support all 3 cases. It gives OK performance for (1) and (2), and poor performance for (3). That could be viewed as a future development task, which perhaps the

Re: [HACKERS] wip: functions median and percentile

2010-10-05 Thread Hitoshi Harada
2010/10/5 Dean Rasheed dean.a.rash...@gmail.com: On 4 October 2010 18:22, Robert Haas robertmh...@gmail.com wrote: On Mon, Oct 4, 2010 at 2:58 AM, Dean Rasheed dean.a.rash...@gmail.com wrote: That requires a new sort for each row. I generated this with a minor tweak to Pavel's patch to just

Re: [HACKERS] wip: functions median and percentile

2010-10-05 Thread Dean Rasheed
On 5 October 2010 07:04, Hitoshi Harada umi.tan...@gmail.com wrote: 2010/10/5 Dean Rasheed dean.a.rash...@gmail.com: On 4 October 2010 18:22, Robert Haas robertmh...@gmail.com wrote: On Mon, Oct 4, 2010 at 2:58 AM, Dean Rasheed dean.a.rash...@gmail.com wrote: That requires a new sort for

Re: [HACKERS] wip: functions median and percentile

2010-10-05 Thread Hitoshi Harada
2010/10/5 Dean Rasheed dean.a.rash...@gmail.com: On 5 October 2010 07:04, Hitoshi Harada umi.tan...@gmail.com wrote: Extrapolating from few quick timing tests, even in the best case, on my machine, it would take 7 days for the running median to use up 100MB, and 8 years for it to use 2GB. So

Re: [HACKERS] wip: functions median and percentile

2010-10-05 Thread Dean Rasheed
On 5 October 2010 13:14, Hitoshi Harada umi.tan...@gmail.com wrote: 2010/10/5 Dean Rasheed dean.a.rash...@gmail.com: On 5 October 2010 07:04, Hitoshi Harada umi.tan...@gmail.com wrote: Extrapolating from few quick timing tests, even in the best case, on my machine, it would take 7 days for the

Re: [HACKERS] wip: functions median and percentile

2010-10-04 Thread Hitoshi Harada
2010/10/4 Greg Stark gsst...@mit.edu: On Sun, Oct 3, 2010 at 7:06 AM, Hitoshi Harada umi.tan...@gmail.com wrote: And I'm now thinking about how to make median happen in window aggregate. If you were to do this by extending tuplesort what extra features would tuplesort need? I don't think we

Re: [HACKERS] wip: functions median and percentile

2010-10-04 Thread Dean Rasheed
On 4 October 2010 07:36, Hitoshi Harada umi.tan...@gmail.com wrote: 2010/10/4 Greg Stark gsst...@mit.edu: On Sun, Oct 3, 2010 at 7:06 AM, Hitoshi Harada umi.tan...@gmail.com wrote: And I'm now thinking about how to make median happen in window aggregate. If you were to do this by extending

Re: [HACKERS] wip: functions median and percentile

2010-10-04 Thread Greg Stark
On Sun, Oct 3, 2010 at 11:58 PM, Dean Rasheed dean.a.rash...@gmail.com wrote: The problem is that performance really sucks, because it is an O(n^2 log(n)) algorithm. I don't see an easy way around that without significant new infrastructure, as Greg describes, or a completely different

Re: [HACKERS] wip: functions median and percentile

2010-10-04 Thread Robert Haas
On Mon, Oct 4, 2010 at 2:58 AM, Dean Rasheed dean.a.rash...@gmail.com wrote: That requires a new sort for each row. I generated this with a minor tweak to Pavel's patch to just restart the tuplesort each time (the quick-fix solution). The problem is that performance really sucks, because it is

Re: [HACKERS] wip: functions median and percentile

2010-10-04 Thread Dean Rasheed
On 4 October 2010 18:22, Robert Haas robertmh...@gmail.com wrote: On Mon, Oct 4, 2010 at 2:58 AM, Dean Rasheed dean.a.rash...@gmail.com wrote: That requires a new sort for each row. I generated this with a minor tweak to Pavel's patch to just restart the tuplesort each time (the quick-fix

Re: [HACKERS] wip: functions median and percentile

2010-10-03 Thread Hitoshi Harada
2010/10/2 Pavel Stehule pavel.steh...@gmail.com: Hello updated version  * memsort removed  * window aggregate support blocked I ran this patch and it looks good for committer. Just one thing, in src/backend/utils/adt/Makefile median.o to compile the new file is missing. And I'm now thinking

Re: [HACKERS] wip: functions median and percentile

2010-10-03 Thread Greg Stark
On Sun, Oct 3, 2010 at 7:06 AM, Hitoshi Harada umi.tan...@gmail.com wrote: And I'm now thinking about how to make median happen in window aggregate. If you were to do this by extending tuplesort what extra features would tuplesort need? Would tuplesort need the ability to insert additional

Re: [HACKERS] wip: functions median and percentile

2010-10-03 Thread Pavel Stehule
Hello 2010/10/3 Hitoshi Harada umi.tan...@gmail.com: 2010/10/2 Pavel Stehule pavel.steh...@gmail.com: Hello updated version  * memsort removed  * window aggregate support blocked I ran this patch and it looks good for committer. Just one thing, in src/backend/utils/adt/Makefile median.o

Re: [HACKERS] wip: functions median and percentile

2010-10-01 Thread Hitoshi Harada
2010/9/26 Pavel Stehule pavel.steh...@gmail.com: Hello, there is updated version - with support of window clause. The limits are work_mem for using inside window aggregate or unlimited when it is used as standard query. This patch needs a few work - can share a compare functionality with

Re: [HACKERS] wip: functions median and percentile

2010-10-01 Thread Pavel Stehule
Hello 2010/10/1 Hitoshi Harada umi.tan...@gmail.com: 2010/9/26 Pavel Stehule pavel.steh...@gmail.com: Hello, there is updated version - with support of window clause. The limits are work_mem for using inside window aggregate or unlimited when it is used as standard query. This patch needs

Re: [HACKERS] wip: functions median and percentile

2010-10-01 Thread Tom Lane
Hitoshi Harada umi.tan...@gmail.com writes: 2010/9/26 Pavel Stehule pavel.steh...@gmail.com: This patch needs a few work - can share a compare functionality with tuplesort.c, but I would to verify a concept now. Sorry for delay. I read the patch and it seems the result is sane. For window

Re: [HACKERS] wip: functions median and percentile

2010-10-01 Thread Pavel Stehule
2010/10/1 Tom Lane t...@sss.pgh.pa.us: Hitoshi Harada umi.tan...@gmail.com writes: 2010/9/26 Pavel Stehule pavel.steh...@gmail.com: This patch needs a few work - can share a compare functionality with tuplesort.c, but I would to verify a concept now. Sorry for delay. I read the patch and it

Re: [HACKERS] wip: functions median and percentile

2010-10-01 Thread Hitoshi Harada
2010/10/1 Tom Lane t...@sss.pgh.pa.us: Hitoshi Harada umi.tan...@gmail.com writes: 2010/9/26 Pavel Stehule pavel.steh...@gmail.com: This patch needs a few work - can share a compare functionality with tuplesort.c, but I would to verify a concept now. Sorry for delay. I read the patch and it

Re: [HACKERS] wip: functions median and percentile

2010-10-01 Thread Tom Lane
Hitoshi Harada umi.tan...@gmail.com writes: 2010/10/1 Tom Lane t...@sss.pgh.pa.us: If this patch tries to force the entire sort to happen in memory, it is not committable. What about array_agg()? Doesn't it exceed memory even if the huge data come in? Yeah, but for array_agg the user

Re: [HACKERS] wip: functions median and percentile

2010-10-01 Thread Robert Haas
On Fri, Oct 1, 2010 at 10:11 AM, Hitoshi Harada umi.tan...@gmail.com wrote: 2010/10/1 Tom Lane t...@sss.pgh.pa.us: Hitoshi Harada umi.tan...@gmail.com writes: 2010/9/26 Pavel Stehule pavel.steh...@gmail.com: This patch needs a few work - can share a compare functionality with tuplesort.c, but

Re: [HACKERS] wip: functions median and percentile

2010-10-01 Thread Hitoshi Harada
2010/10/1 Tom Lane t...@sss.pgh.pa.us: Hitoshi Harada umi.tan...@gmail.com writes: 2010/10/1 Tom Lane t...@sss.pgh.pa.us: If this patch tries to force the entire sort to happen in memory, it is not committable. What about array_agg()? Doesn't it exceed memory even if the huge data come in?

Re: [HACKERS] wip: functions median and percentile

2010-10-01 Thread Tom Lane
Hitoshi Harada umi.tan...@gmail.com writes: Another suggestion? The implementation I would've expected to see is to do the sort and then have two code paths for retrieving the median, depending on whether the sort result is all in memory or not. regards, tom lane --

Re: [HACKERS] wip: functions median and percentile

2010-10-01 Thread Kevin Grittner
Tom Lane t...@sss.pgh.pa.us wrote: Hitoshi Harada umi.tan...@gmail.com writes: Another suggestion? The implementation I would've expected to see is to do the sort and then have two code paths for retrieving the median, depending on whether the sort result is all in memory or not. Would it

Re: [HACKERS] wip: functions median and percentile

2010-10-01 Thread Hitoshi Harada
2010/10/2 Tom Lane t...@sss.pgh.pa.us: Hitoshi Harada umi.tan...@gmail.com writes: Another suggestion? The implementation I would've expected to see is to do the sort and then have two code paths for retrieving the median, depending on whether the sort result is all in memory or not. Hm?

Re: [HACKERS] wip: functions median and percentile

2010-10-01 Thread Tom Lane
Hitoshi Harada umi.tan...@gmail.com writes: 2010/10/2 Tom Lane t...@sss.pgh.pa.us: The implementation I would've expected to see is to do the sort and then have two code paths for retrieving the median, depending on whether the sort result is all in memory or not. Hm? The problem we

Re: [HACKERS] wip: functions median and percentile

2010-10-01 Thread Hitoshi Harada
2010/10/2 Tom Lane t...@sss.pgh.pa.us: Hitoshi Harada umi.tan...@gmail.com writes: 2010/10/2 Tom Lane t...@sss.pgh.pa.us: The implementation I would've expected to see is to do the sort and then have two code paths for retrieving the median, depending on whether the sort result is all in

Re: [HACKERS] wip: functions median and percentile

2010-10-01 Thread Hitoshi Harada
2010/10/2 Kevin Grittner kevin.gritt...@wicourts.gov: Tom Lane t...@sss.pgh.pa.us wrote: Hitoshi Harada umi.tan...@gmail.com writes: Another suggestion? The implementation I would've expected to see is to do the sort and then have two code paths for retrieving the median, depending on

Re: [HACKERS] wip: functions median and percentile

2010-10-01 Thread Pavel Stehule
2010/10/1 Hitoshi Harada umi.tan...@gmail.com: 2010/10/2 Tom Lane t...@sss.pgh.pa.us: Hitoshi Harada umi.tan...@gmail.com writes: 2010/10/2 Tom Lane t...@sss.pgh.pa.us: The implementation I would've expected to see is to do the sort and then have two code paths for retrieving the median,

Re: [HACKERS] wip: functions median and percentile

2010-10-01 Thread Pavel Stehule
Hello updated version * memsort removed * window aggregate support blocked Regards Pavel 2010/10/1 Pavel Stehule pavel.steh...@gmail.com: 2010/10/1 Hitoshi Harada umi.tan...@gmail.com: 2010/10/2 Tom Lane t...@sss.pgh.pa.us: Hitoshi Harada umi.tan...@gmail.com writes: 2010/10/2 Tom Lane

Re: [HACKERS] wip: functions median and percentile

2010-09-26 Thread Pavel Stehule
Hello, there is updated version - with support of window clause. The limits are work_mem for using inside window aggregate or unlimited when it is used as standard query. This patch needs a few work - can share a compare functionality with tuplesort.c, but I would to verify a concept now.

Re: [HACKERS] wip: functions median and percentile

2010-09-23 Thread Pavel Stehule
Hello 2010/9/22 Hitoshi Harada umi.tan...@gmail.com: 2010/9/22 Pavel Stehule pavel.steh...@gmail.com: Hello I found probably hard problem in cooperation with window functions :( tuplesort_begin_datum creates child context inside aggcontext. This context is used for tuplestore. But when

Re: [HACKERS] wip: functions median and percentile

2010-09-23 Thread Pavel Stehule
Hello I moved a median function to core. + doc part + regress test Regards Pavel Stehule 2010/9/20 Hitoshi Harada umi.tan...@gmail.com: 2010/8/19 Pavel Stehule pavel.steh...@gmail.com: Hello I am sending a prototype implementation of functions median and percentile. This implementation

Re: [HACKERS] wip: functions median and percentile

2010-09-23 Thread Pavel Stehule
sorry little bit fixed patch Pavel 2010/9/23 Pavel Stehule pavel.steh...@gmail.com: Hello I moved a median function to core. + doc part + regress test Regards Pavel Stehule 2010/9/20 Hitoshi Harada umi.tan...@gmail.com: 2010/8/19 Pavel Stehule pavel.steh...@gmail.com: Hello I

Re: [HACKERS] wip: functions median and percentile

2010-09-23 Thread Hitoshi Harada
2010/9/23 Pavel Stehule pavel.steh...@gmail.com: Hello 2010/9/22 Hitoshi Harada umi.tan...@gmail.com: 2010/9/22 Pavel Stehule pavel.steh...@gmail.com: Hello I found probably hard problem in cooperation with window functions :( maybe I was confused. I found a other possible problems. The

Re: [HACKERS] wip: functions median and percentile

2010-09-23 Thread Pavel Stehule
2010/9/23 Hitoshi Harada umi.tan...@gmail.com: 2010/9/23 Pavel Stehule pavel.steh...@gmail.com: Hello 2010/9/22 Hitoshi Harada umi.tan...@gmail.com: 2010/9/22 Pavel Stehule pavel.steh...@gmail.com: Hello I found probably hard problem in cooperation with window functions :( maybe I was

Re: [HACKERS] wip: functions median and percentile

2010-09-23 Thread David Fetter
On Thu, Sep 23, 2010 at 08:27:38PM +0200, Pavel Stehule wrote: 2010/9/23 Hitoshi Harada umi.tan...@gmail.com: 2010/9/23 Pavel Stehule pavel.steh...@gmail.com: Hello 2010/9/22 Hitoshi Harada umi.tan...@gmail.com: 2010/9/22 Pavel Stehule pavel.steh...@gmail.com: Hello I found

Re: [HACKERS] wip: functions median and percentile

2010-09-23 Thread Pavel Stehule
2010/9/23 David Fetter da...@fetter.org: On Thu, Sep 23, 2010 at 08:27:38PM +0200, Pavel Stehule wrote: 2010/9/23 Hitoshi Harada umi.tan...@gmail.com: 2010/9/23 Pavel Stehule pavel.steh...@gmail.com: Hello 2010/9/22 Hitoshi Harada umi.tan...@gmail.com: 2010/9/22 Pavel Stehule

Re: [HACKERS] wip: functions median and percentile

2010-09-21 Thread Pavel Stehule
Hello I found probably hard problem in cooperation with window functions :( tuplesort_begin_datum creates child context inside aggcontext. This context is used for tuplestore. But when this function is called from WindowAgg_Aggregates context - someone drops all child context every iteration,

Re: [HACKERS] wip: functions median and percentile

2010-09-21 Thread Robert Haas
On Tue, Sep 21, 2010 at 4:28 PM, Pavel Stehule pavel.steh...@gmail.com wrote: * Cosmetic coding style should be more appropriate, including trailing white spaces and indentation positions. can you specify where, please? I noticed a lot of problems in this area when working on your \ef / \sf

Re: [HACKERS] wip: functions median and percentile

2010-09-21 Thread Pavel Stehule
2010/9/21 Robert Haas robertmh...@gmail.com: On Tue, Sep 21, 2010 at 4:28 PM, Pavel Stehule pavel.steh...@gmail.com wrote: * Cosmetic coding style should be more appropriate, including trailing white spaces and indentation positions. can you specify where, please? I noticed a lot of

Re: [HACKERS] wip: functions median and percentile

2010-09-21 Thread Hitoshi Harada
2010/9/22 Pavel Stehule pavel.steh...@gmail.com: 2010/9/21 Robert Haas robertmh...@gmail.com: On Tue, Sep 21, 2010 at 4:28 PM, Pavel Stehule pavel.steh...@gmail.com wrote: * Cosmetic coding style should be more appropriate, including trailing white spaces and indentation positions. can you

Re: [HACKERS] wip: functions median and percentile

2010-09-21 Thread Hitoshi Harada
2010/9/22 Pavel Stehule pavel.steh...@gmail.com: Hello I found probably hard problem in cooperation with window functions :( tuplesort_begin_datum creates child context inside aggcontext. This context is used for tuplestore. But when this function is called from WindowAgg_Aggregates context

Re: [HACKERS] wip: functions median and percentile

2010-09-21 Thread Pavel Stehule
2010/9/22 Hitoshi Harada umi.tan...@gmail.com: 2010/9/22 Pavel Stehule pavel.steh...@gmail.com: 2010/9/21 Robert Haas robertmh...@gmail.com: On Tue, Sep 21, 2010 at 4:28 PM, Pavel Stehule pavel.steh...@gmail.com wrote: * Cosmetic coding style should be more appropriate, including trailing

Re: [HACKERS] wip: functions median and percentile

2010-09-21 Thread Pavel Stehule
2010/9/22 Hitoshi Harada umi.tan...@gmail.com: 2010/9/22 Pavel Stehule pavel.steh...@gmail.com: Hello I found probably hard problem in cooperation with window functions :( tuplesort_begin_datum creates child context inside aggcontext. This context is used for tuplestore. But when this

Re: [HACKERS] wip: functions median and percentile

2010-09-19 Thread Hitoshi Harada
2010/8/19 Pavel Stehule pavel.steh...@gmail.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

Re: [HACKERS] wip: functions median and percentile

2010-08-19 Thread Greg Stark
On Thu, Aug 19, 2010 at 11:59 AM, Pavel Stehule pavel.steh...@gmail.com wrote: 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.

Re: [HACKERS] wip: functions median and percentile

2010-08-19 Thread Tom Lane
Greg Stark gsst...@mit.edu writes: On Thu, Aug 19, 2010 at 11:59 AM, Pavel Stehule pavel.steh...@gmail.com wrote: 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

Re: [HACKERS] wip: functions median and percentile

2010-08-19 Thread Robert Haas
On Thu, Aug 19, 2010 at 11:33 AM, Tom Lane t...@sss.pgh.pa.us wrote: Greg Stark gsst...@mit.edu writes: On Thu, Aug 19, 2010 at 11:59 AM, Pavel Stehule pavel.steh...@gmail.com wrote: I am sending a prototype implementation of functions median and percentile. This implementation is very

Re: [HACKERS] wip: functions median and percentile

2010-08-19 Thread David Fetter
On Thu, Aug 19, 2010 at 12:49:45PM -0400, Robert Haas wrote: On Thu, Aug 19, 2010 at 11:33 AM, Tom Lane t...@sss.pgh.pa.us wrote: Greg Stark gsst...@mit.edu writes: On Thu, Aug 19, 2010 at 11:59 AM, Pavel Stehule pavel.steh...@gmail.com wrote: I am sending a prototype implementation of

Re: [HACKERS] wip: functions median and percentile

2010-08-19 Thread Kevin Grittner
David Fetter da...@fetter.org wrote: Median may be useful, but we pretty much can't just call it median. Instead, we need to call it something like left_median or arithmetic_median. I think it would be reasonable, and perhaps preferable, to use just median for the semantics described in

Re: [HACKERS] wip: functions median and percentile

2010-08-19 Thread David Fetter
On Thu, Aug 19, 2010 at 12:12:12PM -0500, Kevin Grittner wrote: David Fetter da...@fetter.org wrote: Median may be useful, but we pretty much can't just call it median. Instead, we need to call it something like left_median or arithmetic_median. I think it would be reasonable, and

Re: [HACKERS] wip: functions median and percentile

2010-08-19 Thread Tom Lane
David Fetter da...@fetter.org writes: On Thu, Aug 19, 2010 at 12:12:12PM -0500, Kevin Grittner wrote: http://www.merriam-webster.com/dictionary/median If you do a google search for median and poke around, you'll find many places where this is the only definition mentioned; the others seem

Re: [HACKERS] wip: functions median and percentile

2010-08-19 Thread Pavel Stehule
2010/8/19 David Fetter da...@fetter.org: On Thu, Aug 19, 2010 at 12:49:45PM -0400, Robert Haas wrote: On Thu, Aug 19, 2010 at 11:33 AM, Tom Lane t...@sss.pgh.pa.us wrote: Greg Stark gsst...@mit.edu writes: On Thu, Aug 19, 2010 at 11:59 AM, Pavel Stehule pavel.steh...@gmail.com wrote: I

Re: [HACKERS] wip: functions median and percentile

2010-08-19 Thread Pavel Stehule
2010/8/19 David Fetter da...@fetter.org: On Thu, Aug 19, 2010 at 12:12:12PM -0500, Kevin Grittner wrote: David Fetter da...@fetter.org wrote: Median may be useful, but we pretty much can't just call it median. Instead, we need to call it something like left_median or arithmetic_median.

Re: [HACKERS] wip: functions median and percentile

2010-08-19 Thread David Fetter
On Thu, Aug 19, 2010 at 01:25:36PM -0400, Tom Lane wrote: David Fetter da...@fetter.org writes: On Thu, Aug 19, 2010 at 12:12:12PM -0500, Kevin Grittner wrote: http://www.merriam-webster.com/dictionary/median If you do a google search for median and poke around, you'll find many places

Re: [HACKERS] wip: functions median and percentile

2010-08-19 Thread Kevin Grittner
Pavel Stehule pavel.steh...@gmail.com wrote: I looked there and Oracle11g use median in common sense. As does Sybase IQ. FWIW, Excel spreadsheets do, too. The chance of the SQL committee picking some other meaning for bare MEDIAN seems vanishingly small; although I have to grant that with

Re: [HACKERS] wip: functions median and percentile

2010-08-19 Thread Tom Lane
David Fetter da...@fetter.org writes: On Thu, Aug 19, 2010 at 01:25:36PM -0400, Tom Lane wrote: A name like arithmetic_median seems much less likely to get blindsided by future standardization. Yep. OTOH, if Pavel's right that Oracle already has an aggregate named median(), it seems quite