Re: btree index and max() - Mailing list pgsql-general

From Bruce Momjian
Subject Re: btree index and max()
Date
Msg-id 200006011924.PAA23802@candle.pha.pa.us
Whole thread Raw
In response to Re: btree index and max()  (Ed Loehr <eloehr@austin.rr.com>)
List pgsql-general
> leonbloy@sinectis.com.ar wrote:
> >
> > => explain select max(rid) from facturas;
> > NOTICE:  QUERY PLAN:
> >
> > Aggregate  (cost=21139.66 rows=342414 width=4)
> >   ->  Seq Scan on facturas  (cost=21139.66 rows=342414 width=4)
> >
> > I understand that the query planner cannot be so clever
> > to grasp that this particular function (max or min)
> > might be evaluated by just travelling the BTREE index.
> > Am I correct?
>
> I believe you are unfortunately correct.  :(

That would be a good optimization.  Let me add it to the TODO list.
Much better than trying to keep the max stored somewhere.

--
  Bruce Momjian                        |  http://www.op.net/~candle
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

pgsql-general by date:

Previous
From: "Ross J. Reedstrom"
Date:
Subject: Re: ALTERING A TABLE
Next
From: Ed Loehr
Date:
Subject: Re: btree index and max()