From: CS DBA <cs_dba@consistentstate.com>
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: pgsql-performance@postgresql.org
Subject: Re: Problem query
Date: Wed, 01 Jun 2011 16:28:33 -0600
Message-ID: <4DE6BD11.6060603@consistentstate.com> (raw)
In-Reply-To: <4DE66AF8020000250003DFB6@gw.wicourts.gov>
References: <4DE69D92.5040407@consistentstate.com>
<4DE66AF8020000250003DFB6@gw.wicourts.gov>
On 06/01/2011 03:38 PM, Kevin Grittner wrote:
> 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
I've tried a number of alternates, each one wants to do a seq scan of
the table (including your suggestion above).
--
---------------------------------------------
Kevin Kempter - Constent State
A PostgreSQL Professional Services Company
www.consistentstate.com
---------------------------------------------
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 using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: cs_dba@consistentstate.com, Kevin.Grittner@wicourts.gov
Subject: Re: Problem query
In-Reply-To: <4DE6BD11.6060603@consistentstate.com>
* 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