Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 183B8B5FF0B for ; Wed, 1 Jun 2011 17:40:12 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 96749-02 for ; Wed, 1 Jun 2011 20:40:04 +0000 (UTC) X-Greylist: delayed 00:20:27.590868 by SQLgrey-1.7.6 Received: from mail-pv0-f174.google.com (mail-pv0-f174.google.com [74.125.83.174]) by mail.postgresql.org (Postfix) with ESMTP id 063D3B5FF82 for ; Wed, 1 Jun 2011 17:40:03 -0300 (ADT) Received: by pvg12 with SMTP id 12so81821pvg.19 for ; Wed, 01 Jun 2011 13:40:03 -0700 (PDT) Received: by 10.142.207.4 with SMTP id e4mr1092700wfg.288.1306959253611; Wed, 01 Jun 2011 13:14:13 -0700 (PDT) Received: from issac.consistentstate.com (173-164-51-9-colorado.hfc.comcastbusiness.net [173.164.51.9]) by mx.google.com with ESMTPS id q13sm827605wfd.23.2011.06.01.13.14.12 (version=SSLv3 cipher=OTHER); Wed, 01 Jun 2011 13:14:12 -0700 (PDT) Message-ID: <4DE69D92.5040407@consistentstate.com> Date: Wed, 01 Jun 2011 14:14:10 -0600 From: CS DBA User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Problem query Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201106/5 X-Sequence-Number: 43938 Hi All; We have a table with approx 200 columns. about a dozen columns are text data types and the rest are a mix of integers , bigint's and double precision types. The table has about 25million rows. 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 ) I've tried to split the query up but made little progress, pri_num and tds_cx_ind are bigint's and cxs_ind_2 is an integer The table has an index on all 3 columns (3 separate indexes) Anyone have any thoughts on tuning this query? -- --------------------------------------------- Kevin Kempter - Constent State A PostgreSQL Professional Services Company www.consistentstate.com ---------------------------------------------