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

From Peter Geoghegan
Subject Re: Avoid sorting when doing an array_agg
Date
Msg-id CAH2-Wz=2fLpKNKkUUda4Od0k4bGzoeHZOLNSWzjp4v9VsCk74w@mail.gmail.com
Whole thread Raw
In response to Re: Avoid sorting when doing an array_agg  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Responses Re: Avoid sorting when doing an array_agg
Re: Avoid sorting when doing an array_agg
List pgsql-general
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.

--
Peter Geoghegan


pgsql-general by date:

Previous
From: Paul Ramsey
Date:
Subject: Re: Extensions and privileges in public schema
Next
From: Pavel Stehule
Date:
Subject: Re: Avoid sorting when doing an array_agg