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

From Bruno Wolff III
Subject Re: cost of CREATE VIEW ... AS SELECT DISTINCT
Date
Msg-id 20050329132941.GA27251@wolff.to
Whole thread Raw
In response to Re: cost of CREATE VIEW ... AS SELECT DISTINCT  (T E Schmitz <mailreg@numerixtechnology.de>)
Responses Re: cost of CREATE VIEW ... AS SELECT DISTINCT  (T E Schmitz <mailreg@numerixtechnology.de>)
List pgsql-sql
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.


pgsql-sql by date:

Previous
From: 윤동수
Date:
Subject: when using a bound cursor, error found...
Next
From: T E Schmitz
Date:
Subject: Re: cost of CREATE VIEW ... AS SELECT DISTINCT