Re: optimizer question - Mailing list pgsql-hackers

From mlw
Subject Re: optimizer question
Date
Msg-id 3BC6C4ED.8F9685CD@mohawksoft.com
Whole thread Raw
In response to Re: optimizer question  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-hackers
Bruce Momjian wrote:
> 
> > "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?

That would be real cool. I don't know of any database that does that. (I do
know that our Oracle 8i does not)


On a side note (can of worms?) is there the notion of a "rule based optimizer"
vs the cost based optimizer in Postgres?


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Glitch in handling of postmaster -o options
Next
From: Oleg Bartunov
Date:
Subject: New contrib/tsearch module for 7.2