Re: pgstat SRF?

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pgstat SRF?
Date: 2008-04-21 14:09:36
Message-ID: 20080421160936.3a72bf6a@mha-laptop
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Magnus Hagander <magnus(at)hagander(dot)net> writes:
> > While looking over the statistics-for-functions patch
> > (http://archives.postgresql.org/pgsql-patches/2008-03/msg00300.php),
> > I came back to a thought I've had before - why do we keep one
> > function per column for pgstat functions, instead of using a set
> > returning function? Is there some actual reason for this, or is it
> > just legacy from a time when it was (much) harder to write SRFs?
>
> I think it's so that you can build your own stats views instead of
> being compelled to select the data someone thought was good for you.

You can still do that if it's an SRF. You could even make the SRF take
an optional argument to either return a single value (filtered the same
way the individual functions are) or when this one is set to NULL,
return the whole table.

It would make the overhead a lot lower in the most common case ("SELECT
* FROM pg_stat_<somethingorother>"), while only adding a little in the
other cases, I think.

Though I'm not sure that overhead is big enough to care about in the
first place, but if you're VIEWs are longish it could be...

//Magnus

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2008-04-21 14:12:37 Re: TODO, FAQs to Wiki?
Previous Message Joshua D. Drake 2008-04-21 14:06:54 Re: TODO, FAQs to Wiki?