Skip site navigation (1) Skip section navigation (2)

Re: optimizer question

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Reinoud van Leeuwen" <reinoud(at)xs4all(dot)nl>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: optimizer question
Date: 2001-09-26 15:19:00
Message-ID: 946.1001517540@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
"Reinoud van Leeuwen" <reinoud(at)xs4all(dot)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

In response to

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2001-09-26 16:10:00
Subject: Spinlock performance improvement proposal
Previous:From: Tom LaneDate: 2001-09-26 15:15:00
Subject: Re: PERFORMANCE IMPROVEMENT by mapping WAL FILES

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group