Re: Avoid sorting when doing an array_agg - Mailing list pgsql-general

From Pavel Stehule
Subject Re: Avoid sorting when doing an array_agg
Date
Msg-id CAFj8pRCL3kvLgF_+Z=OzVuR_jsg52hD21eZE+benMNSbSLsDXQ@mail.gmail.com
Whole thread Raw
In response to Re: Avoid sorting when doing an array_agg  (Peter Geoghegan <pg@bowt.ie>)
List pgsql-general


2016-12-04 23:12 GMT+01:00 Peter Geoghegan <pg@bowt.ie>:
On Sat, Dec 3, 2016 at 5:20 PM, Tomas Vondra
<tomas.vondra@2ndquadrant.com> wrote:
> So the sort is probably slow because of CPU, as it compares strings. In
> some locales that may be very expensive - not sure which locale is used
> in this case, as it was not mentioned.

I wonder what it would take to teach the optimizer to consider the
possibility of a "collation strength reduction". In other words, for
aggregates that perform a sort (or for aggregates that rely on the
presence of a sort node without there being some other dependency on
the sort node), it should be possible for the optimizer to determine
that it would be just fine to use the C locale, since the user isn't
entitled to assume anything about the exact sort order. There are of
course cases where this can make a huge difference.

it is pretty good idea.

Regards

Pavel


 

--
Peter Geoghegan


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

pgsql-general by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Avoid sorting when doing an array_agg
Next
From: Martin Collins
Date:
Subject: Re: Postgres and LibreOffice's 'Base'