From: | Decibel! <decibel(at)decibel(dot)org> |
---|---|
To: | Sam Mason <sam(at)samason(dot)me(dot)uk> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: writing a MIN(RECORD) aggregate |
Date: | 2008-03-24 22:27:04 |
Message-ID: | 04092B5D-B935-4FCA-9587-4FE65E47E0A1@decibel.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mar 20, 2008, at 2:23 PM, Sam Mason wrote:
> I'm trying to write a version of the MIN aggregate for values of
> RECORD
> type. I'm somewhat stuck on getting type information about the
> argument
> out, I can determine how many attributes it's got but I can't seem
> to do
> any better than that. Does anyone have any good pointers into the
> code
> for places to help me understand what's happening?
>
> The reason for doing this is mainly because I think it'd be nicer
> to be
> doing things like:
>
> SELECT i, (MIN((j,k))).k
> FROM tbl
> GROUP BY i;
How is that any better than SELECT i, min(k) FROM tbl GROUP BY i ?
> instead of:
>
> SELECT DISTINCT ON (i) i, k
> FROM tbl
> ORDER BY i,j,k;
>
> Which as far as I can tell should produce identical results, except
> the
> first has cleaner semantics. It also allows you to combine MIN and
> MAX
> in the same query, giving the value of k for the smallest and
> largest j
> in this example--requiring two queries if it was done using the
> DISTINCT
> ON method.
I don't see how min(record) even allows for that.
I'm not saying that min/avg/max/etc(RECORD) wouldn't be useful; I'm
just failing to see the use in these examples.
--
Decibel!, aka Jim C. Nasby, Database Architect decibel(at)decibel(dot)org
Give your computer some brain candy! www.distributed.net Team #1828
From | Date | Subject | |
---|---|---|---|
Next Message | Marc G. Fournier | 2008-03-24 22:30:44 | Re: New email list for emergency communications |
Previous Message | Marc G. Fournier | 2008-03-24 22:20:27 | Re: New email list for emergency communications |