From: Tom Lane <tgl@sss.pgh.pa.us>
To: mailreg@numerixtechnology.de
Cc: Bruno Wolff III <bruno@wolff.to>
Cc: Scott Marlowe <smarlowe@g2switchworks.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: cost of CREATE VIEW ... AS SELECT DISTINCT
Date: Tue, 29 Mar 2005 10:54:08 -0500
Message-ID: <22694.1112111648@sss.pgh.pa.us> (raw)
In-Reply-To: <4249564B.1000807@numerixtechnology.de>
References: <42487A6D.6020506@numerixtechnology.de>
<1112047463.22988.25.camel@state.g2switchworks.com>
<424928D8.7060705@numerixtechnology.de>
<20050329132941.GA27251@wolff.to>
<4249564B.1000807@numerixtechnology.de>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, mailreg@numerixtechnology.de, bruno@wolff.to, smarlowe@g2switchworks.com
Subject: Re: cost of CREATE VIEW ... AS SELECT DISTINCT
In-Reply-To: <22694.1112111648@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox