Re: optimizer question - Mailing list pgsql-hackers

From Tom Lane
Subject Re: optimizer question
Date
Msg-id 946.1001517540@sss.pgh.pa.us
Whole thread Raw
In response to optimizer question  ("Reinoud van Leeuwen" <reinoud@xs4all.nl>)
Responses Re: optimizer question  (Bruce Momjian <pgman@candle.pha.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;
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: PERFORMANCE IMPROVEMENT by mapping WAL FILES
Next
From: Tom Lane
Date:
Subject: Spinlock performance improvement proposal