Re: Ordering of data on calls to user defined aggregate.

From: "Joel Burton" <joel(at)joelburton(dot)com>
To: "Tim Hart" <timjhart(at)shaw(dot)ca>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Ordering of data on calls to user defined aggregate.
Date: 2002-05-18 21:13:04
Message-ID: 20020518211304.5F3522B811@temp.joelburton.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tim Hart <timjhart(at)shaw(dot)ca> said:

> So I tried a query like this:
>
> select fk, concat_with_and(name) from ( select fk, name from foo order
> by fk, name) sub_select group by fk;
>
> From just eyeballing the first 10 to 12 pages of the results, all but 2
> records had the names in alphabetical order. So I removed the subselect
> and ran the query again - this time paying attention to the ordering
> within names. Very few entries in the 'names' column were in
> alphabetical order at all.

Hmmm... in my (small) test case, they were all alphabetized.

I didn't think that subquery sort orders were guaranteed, though, so perhaps it's okay that yours weren't.

Can you try with GROUP BY fk, name in the subquery? That works, too, on my small test case, and that should be guaranteed behavior in a subquery. Let's see how that works with your data set.

- J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-05-18 21:56:13 Re: Ordering of data on calls to user defined aggregate.
Previous Message Tom Lane 2002-05-18 20:19:09 Re: Force a merge join?