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-22 04:44:58
Message-ID: AANLkTik__bHQ8huADCpuN63w0eKdWnNHq0nSXdQ27R9N@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-rrreviewers

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.
>

It is bad premise. Inside a aggregates I don't have a control over
memory context. There missing one level of persistent memory context
where I can put a child context - but this context should be created
outside - some like group context.

Pavel

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David E. Wheeler 2010-09-22 04:46:03 Re: Multi-branch committing in git, revisited
Previous Message Jesper Krogh 2010-09-22 04:41:01 Re: Make tuples_per_page pr. table configureable.

Browse pgsql-rrreviewers by date

  From Date Subject
Next Message Marko Tiikkaja 2010-09-22 23:59:15 Re: top-level DML under CTEs
Previous Message Pavel Stehule 2010-09-22 04:36:24 Re: wip: functions median and percentile