Re: aggregate function for median calculation - Mailing list pgsql-general

From Tom Lane
Subject Re: aggregate function for median calculation
Date
Msg-id 8180.992991226@sss.pgh.pa.us
Whole thread Raw
In response to Re: aggregate function for median calculation  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: aggregate function for median calculation  ("Thalis A. Kalfigopoulos" <thalis@cs.pitt.edu>)
List pgsql-general
Peter Eisentraut <peter_e@gmx.net> writes:
> Sure, you create a (static) global variable and reallocate memory for it
> in each call and free it by the finalizer function.

A static would be a bad idea (consider a query with multiple instances
of this aggregate being evaluated in parallel).

But there's no reason that the transition function can't palloc a larger
and larger chunk of memory for each result (as long as you don't run out
of memory, anyway).

            regards, tom lane

pgsql-general by date:

Previous
From: "Thalis A. Kalfigopoulos"
Date:
Subject: postgres.h missing?
Next
From: Tom Lane
Date:
Subject: Re: postgres.h missing?