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

Re: Proof of concept for MIN/MAX optimization

From: Mark Kirkwood <markir(at)paradise(dot)net(dot)nz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: Proof of concept for MIN/MAX optimization
Date: 2005-04-14 04:11:13
Message-ID: 425DED61.5080104@paradise.net.nz (view raw or flat)
Thread:
Lists: pgsql-patches
Tom Lane wrote:
> I haven't done the work yet to add a column to pg_aggregate, so this
> just knows about optimizing a couple of hard-wired cases (int4 and
> text).  Other than that it's reasonably complete, I think.  Comments?
>

Looks good :

regression=# explain select max(unique1) from tenk1;
                                                QUERY PLAN
---------------------------------------------------------------------------------------------------------
  Result  (cost=0.15..0.16 rows=1 width=0)
    InitPlan
      ->  Limit  (cost=0.00..0.15 rows=1 width=4)
            ->  Index Scan Backward using tenk1_unique1 on tenk1 
(cost=0.00..1512.59 rows=10000 width=4)
(4 rows)


The handling of nulls is a little unexpected (still todo?) :

regression=# insert into tenk2 (unique1,unique2) values(null, 10000);
INSERT 0 1
regression=# select max(unique1) from tenk2;
  max
-----

(1 row)
regression=# set enable_indexscan=0;
SET
regression=# select max(unique1) from tenk2;
  max
------
  9999
(1 row)

cheers

Mark



In response to

Responses

pgsql-patches by date

Next:From: Tom LaneDate: 2005-04-14 06:58:12
Subject: Re: Proof of concept for MIN/MAX optimization
Previous:From: Greg Sabino MullaneDate: 2005-04-13 01:22:33
Subject: Re: Remove unneeded left joins from psql

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