Re: SQL syntax extentions - to put postgres ahead in the race

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: Ram Nathaniel <ram_nathaniel(at)hotmail(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: SQL syntax extentions - to put postgres ahead in the race
Date: 2004-08-06 07:07:27
Message-ID: 8583.1091776047@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> writes:
> On Thu, 5 Aug 2004, Ram Nathaniel wrote:
>> 2) aggregated concatenation:

> Theoretically, you should be able to do this right now in PostgreSQL with
> user defined aggregates (although you can't pass a second argument
> currently for the separator).

There's nothing particularly stopping us from supporting
multiple-argument aggregates, except a lack of round tuits.
(I suppose we'd want to rethink the syntax of CREATE AGGREGATE,
but otherwise it ought to be pretty straightforward.)

> I believe that an ordered subquery in FROM
> will currently allow you to get an ordered aggregate, or perhaps you'd
> have to turn off hash aggregation, but I think you should be able to get
> it to keep the ordering.

I think you would want to ORDER BY twice:

SELECT class, list(student) from
(select class, student from grades order by class, student) ss
order by class;

It looks like (at least in CVS tip) planner.c will take into account the
relative costs of doing a GroupAgg vs doing a HashAgg and re-sorting,
but I'm too tired to try it right now...

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Achilleus Mantzios 2004-08-06 09:17:19 Re: retrieve the tables names based on the owner
Previous Message Stephan Szabo 2004-08-06 05:22:33 Re: SQL syntax extentions - to put postgres ahead in the race