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