| From: | Greg Stark <gsstark(at)mit(dot)edu> |
|---|---|
| To: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | Bad query optimisation |
| Date: | 2002-11-30 22:47:54 |
| Message-ID: | 87znrqwu79.fsf@stark.dyndns.tv |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
This is weird, it seems like min and max aren't being optimised symmetrically.
It seems like both of these should result in similar plans and run equally
fast. Instead the first is actually really slow and the second is perfectly
quick.
foo=# explain select max(postalcode) from postalcodes where postalcode < 'K0C1N2';
Aggregate (cost=123.59..123.59 rows=1 width=10)
-> Index Scan using postalcodes_pkey on postalcodes (cost=0.00..120.50 rows=1234 width=10)
foo=# explain select min(postalcode) from postalcodes where postalcode > 'K0C1N2';
Aggregate (cost=10373.45..10373.45 rows=1 width=10)
-> Seq Scan on postalcodes (cost=0.00..9697.11 rows=270535 width=10)
--
greg
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Christopher Kings-Lynne | 2002-11-30 22:57:05 | Re: Bad query optimisation |
| Previous Message | Greg Stark | 2002-11-30 22:41:09 | Newbie hacker looking to get started |