Re: cost of CREATE VIEW ... AS SELECT DISTINCT

Поиск
Список
Период
Сортировка
От T E Schmitz
Тема Re: cost of CREATE VIEW ... AS SELECT DISTINCT
Дата
Msg-id 424928D8.7060705@numerixtechnology.de
обсуждение исходный текст
Ответ на Re: cost of CREATE VIEW ... AS SELECT DISTINCT  (Scott Marlowe <smarlowe@g2switchworks.com>)
Ответы Re: cost of CREATE VIEW ... AS SELECT DISTINCT  (Sean Davis <sdavis2@mail.nih.gov>)
Re: cost of CREATE VIEW ... AS SELECT DISTINCT  (Bruno Wolff III <bruno@wolff.to>)
Список pgsql-sql
Hello Scott,

Scott Marlowe wrote:
> On Mon, 2005-03-28 at 15:43, T E Schmitz wrote:
> 
>>How expensive would it be to maintain the following VIEW:
>>
>>CREATE VIEW origin AS SELECT DISTINCT origin FROM transaktion
>>
>>if there is in index on transaktion.origin; the table transaktion has 
>>thousands of records and there are only a few distinct origin?
> 
> 
> The cost will only be encurred when running the view.  if you want
> materialized views (which WOULD have maintenance costs) you'll have to

Thank you for the pointer - that might come in handy for another scenario.

> The cost of executing that view should be the same as the cost of
> running the query by hand.

I did an EXPLAIN ANALYZE and a sequential scan was carried out despite 
the index I had on the column. Maybe this is because I only have very 
few records in my test DB.

Would the "SELECT DISTINCT origin" always cause a sequential table scan 
regardless whether there is an index on the origin column or not?



-- 


Regards/Gruß,

Tarlika Elisabeth Schmitz


В списке pgsql-sql по дате отправления:

Предыдущее
От: Scott Marlowe
Дата:
Сообщение: Re: cost of CREATE VIEW ... AS SELECT DISTINCT
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: Merging item codes using referential integrity