From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: CS DBA <cs_dba@consistentstate.com>
To: pgsql-performance@postgresql.org
Subject: Re: Problem query
Date: Wed, 01 Jun 2011 16:38:16 -0500
Message-ID: <4DE66AF8020000250003DFB6@gw.wicourts.gov> (raw)
In-Reply-To: <4DE69D92.5040407@consistentstate.com>
References: <4DE69D92.5040407@consistentstate.com>
CS DBA <cs_dba@consistentstate.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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: Kevin.Grittner@wicourts.gov, cs_dba@consistentstate.com
Subject: Re: Problem query
In-Reply-To: <4DE66AF8020000250003DFB6@gw.wicourts.gov>
References: <4DE69D92.5040407@consistentstate.com> <4DE66AF8020000250003DFB6@gw.wicourts.gov>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox