Re: Speeding up select distinct - Mailing list pgsql-performance

From Greg Stark
Subject Re: Speeding up select distinct
Date
Msg-id 87ekefj98m.fsf@stark.xeocode.com
Whole thread Raw
In response to Re: Speeding up select distinct  (Laurent Martelli <laurent@aopsys.com>)
List pgsql-performance
Laurent Martelli <laurent@aopsys.com> writes:

>   PFC>     SELECT owner from pictures group by owner;
>
> That's a slight improvement, but there's still a seq scan on pictures:

It should be a sequential scan. An index will be slower.

>  HashAggregate  (cost=114.38..114.38 rows=21 width=4) (actual time=7.585..7.605 rows=21 loops=1)
>    ->  Seq Scan on pictures  (cost=0.00..103.70 rows=4270 width=4) (actual time=0.015..3.272 rows=4270 loops=1)
>  Total runtime: 7.719 ms

That's the best plan for this query.

--
greg

pgsql-performance by date:

Previous
From: David Brown
Date:
Subject: Re: multi-column index
Next
From: Tom Lane
Date:
Subject: Re: multi-column index