Re: optimizer question - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: optimizer question
Date
Msg-id 200110112117.f9BLH4N14100@candle.pha.pa.us
Whole thread Raw
In response to Re: optimizer question  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
> "Reinoud van Leeuwen" <reinoud@xs4all.nl> writes:
> > I have a table that contains almost 8 milion rows. The primary key is a 
> > sequence, so the index should have a good distribution. Why does the 
> > optimizer refuse to use the index for getting the maximum value?
> 
> The optimizer has no idea that max() has anything to do with indexes.
> You could try something like
> 
>     select * from tab order by foo desc limit 1;

Can we consider doing this optimization automatically?

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: CLUSTER TODO item
Next
From: Tom Lane
Date:
Subject: Re: CLUSTER TODO item