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

From T E Schmitz
Subject Re: cost of CREATE VIEW ... AS SELECT DISTINCT
Date
Msg-id 4249564B.1000807@numerixtechnology.de
Whole thread Raw
In response to Re: cost of CREATE VIEW ... AS SELECT DISTINCT  (Bruno Wolff III <bruno@wolff.to>)
Responses Re: cost of CREATE VIEW ... AS SELECT DISTINCT  (Alvaro Herrera <alvherre@dcc.uchile.cl>)
Re: cost of CREATE VIEW ... AS SELECT DISTINCT  (Bruno Wolff III <bruno@wolff.to>)
Re: cost of CREATE VIEW ... AS SELECT DISTINCT  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
Bruno Wolff III wrote:
> On Tue, Mar 29, 2005 at 11:07:20 +0100,
>   T E Schmitz <mailreg@numerixtechnology.de> wrote:
> 
>>Would the "SELECT DISTINCT origin" always cause a sequential table scan 
>>regardless whether there is an index on the origin column or not?
> 
> 
> It's worse than that, SELECT DISTINCT cannot use a hash aggregate plan
> and will need to do a sort to eliminate duplicates. Unless the view
> is used in a way that restricts the candidate rows, this probably isn't going
> to be very fast. You might be better off changing the view to use GROUP BY
> instead of DISTINCT.

As far as I can see (via EXPLAIN), both DISTINCT and GROUP BY will lead 
to a sequentail scan. Is that correct?

If that's the case, I should come up with a different concept to obtain 
a list of ORIGINs.

-- 


Regards/Gruß,

Tarlika Elisabeth Schmitz


pgsql-sql by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: cost of CREATE VIEW ... AS SELECT DISTINCT
Next
From: Alvaro Herrera
Date:
Subject: Re: cost of CREATE VIEW ... AS SELECT DISTINCT