Re: Order by optimisations?

Поиск
Список
Период
Сортировка
От Michael Paesold
Тема Re: Order by optimisations?
Дата
Msg-id 012501c58856$fe0f0790$d501a8c0@zaphod
обсуждение исходный текст
Ответ на Order by optimisations?  (Christopher Kings-Lynne <chriskl@familyhealth.com.au>)
Ответы Re: Order by optimisations?  (Jochem van Dieten <jochemd@gmail.com>)
Список pgsql-hackers
Christopher Kings-Lynne wrote:
> Doesn't seem like it does:
>
> usatest=# explain select * from users_myfoods_map where date='2004-11-21' 
> order by date;
>                                 QUERY PLAN
> ---------------------------------------------------------------------------
>  Sort  (cost=17.17..17.48 rows=123 width=22)
>    Sort Key: date
>    ->  Seq Scan on users_myfoods_map  (cost=0.00..12.90 rows=123 width=22)
>          Filter: (date = '2004-11-21'::date)
> (4 rows)
>
> The sort cost is non-zero.  Or am I not looking at the right thing...

You are looking at the right thing, AFAIK. Well, it seems the planner cannot 
reason that if a field should have only one value, sorting on that field is 
not needed.

I remember there are examples where the planner will know that the input to 
a sort is already sorted and will skip the sort. Tom will be able to explain 
if this here is a reasonable optimization. I *guess* it could be done, with 
some restrictions.

Best Regards,
Michael Paesold 



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

Предыдущее
От: Christopher Kings-Lynne
Дата:
Сообщение: Re: Order by optimisations?
Следующее
От: Michael Fuhr
Дата:
Сообщение: 7.3 regression failures after recent commit