From: | Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au> |
---|---|
To: | Hannu Krosing <hannu(at)skype(dot)net> |
Cc: | Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Order by optimisations? |
Date: | 2005-07-14 09:06:06 |
Message-ID: | 42D62AFE.7090109@familyhealth.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hannu Krosing wrote:
> On K, 2005-07-13 at 16:08 +0800, Christopher Kings-Lynne wrote:
>
>>Hi,
>>
>>Does PostgreSQL do the following optimisation:
>>
>>SELECT * FROM diary WHERE date = '2005-05-01' ORDER BY date;
>>
>>or in fact even better (for my situation)
>>
>>SELECT * FROM diary WHERE date BETWEEN '2005-05-01' AND '2005-05-01'
>>ORDER BY date;
>>
>>Does it know that the input to the sort routine is already sorted and
>>hence is a no-op?
>
>
> Yes
>
> try EXPLAIN ;)
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...
Chris
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paesold | 2005-07-14 09:32:44 | Re: Order by optimisations? |
Previous Message | Koichi Suzuki | 2005-07-14 09:05:35 | Re: A couple of patches for PostgreSQL 64bit support |