From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | mailreg(at)numerixtechnology(dot)de |
Cc: | Bruno Wolff III <bruno(at)wolff(dot)to>, Scott Marlowe <smarlowe(at)g2switchworks(dot)com>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: cost of CREATE VIEW ... AS SELECT DISTINCT |
Date: | 2005-03-29 15:54:08 |
Message-ID: | 22694.1112111648@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
T E Schmitz <mailreg(at)numerixtechnology(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | T E Schmitz | 2005-03-29 16:01:53 | Re: cost of CREATE VIEW ... AS SELECT DISTINCT |
Previous Message | Bruno Wolff III | 2005-03-29 15:07:10 | Re: cost of CREATE VIEW ... AS SELECT DISTINCT |