Re: optimizer question

From: Hannu Krosing <hannu(at)tm(dot)ee>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Reinoud van Leeuwen <reinoud(at)xs4all(dot)nl>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: optimizer question
Date: 2001-10-12 03:28:20
Message-ID: 3BC66354.D6C0BA95@tm.ee
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?

Only if we assume that people do not define their own max() that does
something
that can't be calculated using the above formula like calculating AVG().

---------------
Hannu

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gavin Sherry 2001-10-12 03:35:30 Re: CLUSTER TODO item
Previous Message Tom Lane 2001-10-12 03:25:18 Re: Glitch in handling of postmaster -o options