Re: cost of CREATE VIEW ... AS SELECT DISTINCT - Mailing list pgsql-sql

From Tom Lane
Subject Re: cost of CREATE VIEW ... AS SELECT DISTINCT
Date
Msg-id 22694.1112111648@sss.pgh.pa.us
Whole thread Raw
In response to Re: cost of CREATE VIEW ... AS SELECT DISTINCT  (T E Schmitz <mailreg@numerixtechnology.de>)
List pgsql-sql
T E Schmitz <mailreg@numerixtechnology.de> writes:
> As far as I can see (via EXPLAIN), both DISTINCT and GROUP BY will lead 
> to a sequentail scan. Is that correct?

I'm not sure why you expect something different.  The query requires
visiting every row of the table in any case --- else it might miss
values that occur only once --- therefore a seqscan is most efficient.

The planner will consider plans that involve an indexscan, but only
as a substitute for doing an explicit sort before a uniq-style grouping
step.  Generally the explicit sort will win that comparison.  And a
hash grouping step probably dominates them both.
        regards, tom lane


pgsql-sql by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: cost of CREATE VIEW ... AS SELECT DISTINCT
Next
From: T E Schmitz
Date:
Subject: Re: cost of CREATE VIEW ... AS SELECT DISTINCT