Re: aggregate function for median calculation

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: "Thalis A(dot) Kalfigopoulos" <thalis(at)cs(dot)pitt(dot)edu>, Alex Pilosov <alex(at)pilosoft(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: aggregate function for median calculation
Date: 2001-06-19 22:53:46
Message-ID: 8180.992991226@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Peter Eisentraut <peter_e(at)gmx(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-06-19 22:54:41 Re: postgres.h missing?
Previous Message Thalis A. Kalfigopoulos 2001-06-19 22:04:56 postgres.h missing?