Re: select max() much slower than select min() - Mailing list pgsql-performance

From Dave Dutcher
Subject Re: select max() much slower than select min()
Date
Msg-id 61EE390C385F40A599EF08D89A4D2BC5@tridecap.com
Whole thread Raw
In response to select max() much slower than select min()  (Brian Cox <brian.cox@ca.com>)
List pgsql-performance
> -----Original Message-----
> From: Brian Cox
> Subject: [PERFORM] select max() much slower than select min()
>

> seems like max() shouldn't take any longer than min() and
> certainly not 10 times as long. Any ideas on how to determine
> the max more quickly?


That is odd.  It seems like max should actually have to scan fewer rows than
min should.  It might still be bloat in the table, because unless you did
VACUUM FULL there could still be dead rows.  A vacuum verbose would show if
there is bloat or not.  Also maybe you could try a two column index like
this:

create index test_index on ts_stats_transet_user_interval
(ts_interval_start_time, ts_id);


Dave



pgsql-performance by date:

Previous
From: Kenneth Marshall
Date:
Subject: Re: 8.4 COPY performance regression on Solaris
Next
From: Tom Lane
Date:
Subject: Re: select max() much slower than select min()