Re: Avoid sorting when doing an array_agg

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Peter Geoghegan <pg(at)bowt(dot)ie>
Cc: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, Kiriakos Georgiou <kg(dot)postgresql(at)olympiakos(dot)com>, Alexis Woo <awoo2611(at)gmail(dot)com>, "Psql_General (E-mail)" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Avoid sorting when doing an array_agg
Date: 2016-12-04 22:22:39
Message-ID: CAFj8pRCL3kvLgF_+Z=OzVuR_jsg52hD21eZE+benMNSbSLsDXQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2016-12-04 23:12 GMT+01:00 Peter Geoghegan <pg(at)bowt(dot)ie>:

> On Sat, Dec 3, 2016 at 5:20 PM, Tomas Vondra
> <tomas(dot)vondra(at)2ndquadrant(dot)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(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rich Shepard 2016-12-04 23:54:46 Re: Postgres and LibreOffice's 'Base'
Previous Message Peter Geoghegan 2016-12-04 22:12:06 Re: Avoid sorting when doing an array_agg