Skip site navigation (1) Skip section navigation (2)

Re: wip: functions median and percentile

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Hitoshi Harada <umi(dot)tanuki(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-23 09:35:47
Message-ID: AANLkTikewGkszNhZej8xnCK-Pe251m1Wra_eTpD-unRt@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-rrreviewers
Hello

2010/9/22 Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>:
> 2010/9/22 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)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 - someone drops all child context every
>> iteration, and then tuplestore state is invalid. For this moment we
>> can block using a median function as window function, but it should be
>> solved better - if it is possible - I don't see inside window function
>> implementation.
>
> Does it happen when the window frame starts from not UNBOUNDED
> PRECEDING? In those cases, nodeWindowAgg tries to discard all
> aggregate contexts and to initialize the aggregate state. AFAIK the
> memory context is brand-new although it was reset and its children
> deleted, so if the function is well-formed and initializes its state
> on NULL input, it doesn't cause a problem.

maybe I was confused. I found a other possible problems.

The problem with median function is probably inside a final function
implementation. Actually we request possibility of repetitive call of
final function. But final function call tuplesort_end function and
tuplesort_performsort. These function changes a state of tuplesort.
The most basic question is "who has to call tuplesort_end function and
when?

Regards

Pavel Stehule

>
>
> Regards,
>
>
> --
> Hitoshi Harada
>

In response to

Responses

pgsql-hackers by date

Next:From: Dimitri FontaineDate: 2010-09-23 09:49:09
Subject: Re: Standby registration
Previous:From: Heikki LinnakangasDate: 2010-09-23 09:34:51
Subject: Re: Standby registration

pgsql-rrreviewers by date

Next:From: Pavel StehuleDate: 2010-09-23 13:22:39
Subject: Re: wip: functions median and percentile
Previous:From: Marko TiikkajaDate: 2010-09-23 09:22:54
Subject: Re: top-level DML under CTEs

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group