Re: Faster distinct query? - Mailing list pgsql-general

From David Rowley
Subject Re: Faster distinct query?
Date
Msg-id CAApHDvoWkyQxTq=aS20A_879+micPenOnPA1RWbK8kAuCe8+mA@mail.gmail.com
Whole thread Raw
In response to Re: Faster distinct query?  (Michael Lewis <mlewis@entrata.com>)
List pgsql-general
On Thu, 23 Sept 2021 at 08:21, Michael Lewis <mlewis@entrata.com> wrote:
> select station, array_agg(distinct(channel)) as channels
> FROM(
> SELECT station,channel FROM data GROUP BY station,channel
> ) AS sub
> group by station;

Since the subquery is grouping by station, channel, then there's no
need for the DISTINCT in the aggregate function. Removing that should
remove some tuplestore overhead from the aggregate node.

David



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Faster distinct query?
Next
From: David Rowley
Date:
Subject: Re: Faster distinct query?