Re: optimizer question

From: mlw <markw(at)mohawksoft(dot)com>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: optimizer question
Date: 2001-10-12 10:24:45
Message-ID: 3BC6C4ED.8F9685CD@mohawksoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Bruce Momjian wrote:
>
> > "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;
>
> 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?

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Lockhart 2001-10-12 13:25:57 [Fwd: Postgre SQL Developer - Chicago, IL]
Previous Message Michael Meskes 2001-10-12 08:40:39 Re: Deadlock? idle in transaction