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

From David Rees
Subject Re: select max() much slower than select min()
Date
Msg-id 72dbd3150906191341s74629514w12e201740088dfe8@mail.gmail.com
Whole thread Raw
In response to Re: select max() much slower than select min()  (Brian Cox <brian.cox@ca.com>)
List pgsql-performance
On Fri, Jun 19, 2009 at 1:05 PM, Brian Cox<brian.cox@ca.com> wrote:
> Thanks to all for the analysis and suggestions. Since the number of rows in
> an hour < ~500,000, brute force looks to be a fast solution:
>
> select ts_id from ... where ts_interval_start_time >= ... and ...
>
> This query runs very fast as does a single pass through the ids to find the
> min and max.

Along those lines, couldn't you just have the DB do the work?

select max(ts_id), min(ts_id) from ... where ts_interval_start_time >=
... and ...

Then you don't have to transfer 500k ids across the network...

-Dave

pgsql-performance by date:

Previous
From: Brian Cox
Date:
Subject: Re: select max() much slower than select min()
Next
From: Brian Cox
Date:
Subject: Re: select max() much slower than select min()