Re: Problem query

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "CS DBA" <cs_dba(at)consistentstate(dot)com>, <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Problem query
Date: 2011-06-01 21:38:16
Message-ID: 4DE66AF8020000250003DFB6@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

CS DBA <cs_dba(at)consistentstate(dot)com> wrote:

> The app wants to run a query like this:
>
> select count(pri_num) from max_xtrv_st_t
> where pri_num in (select max(pri_num) from max_xtrv_st_t where 1=1
> group by tds_cx_ind, cxs_ind_2)

Why not something simpler? There are a number of possibilities, and
I don't claim this one is necessarily best (or even error free), but
how about something like?:

select count(*) from
(select distinct max(pri_num)
from max_xtrv_st_t
group by tds_cx_ind, cxs_ind_2) x

-Kevin

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Ross J. Reedstrom 2011-06-01 21:53:15 Re: [PERFORM] Hash Anti Join performance degradation
Previous Message Merlin Moncure 2011-06-01 21:15:24 Re: Problem query