Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 57CC8B619AE for ; Wed, 1 Jun 2011 18:15:31 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 60853-04 for ; Wed, 1 Jun 2011 21:15:24 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com [209.85.216.181]) by mail.postgresql.org (Postfix) with ESMTP id 4A92AB5FBEF for ; Wed, 1 Jun 2011 18:15:24 -0300 (ADT) Received: by qyg14 with SMTP id 14so119399qyg.19 for ; Wed, 01 Jun 2011 14:15:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=jqWhwUTzPYXtZG54caCB2W3jBmCwJN31STR76XtngDA=; b=Z/Zzeao6JaEnsnCUuihtCOJaxY2qnUJXL5mG+KAY+YJGV3cOgEgx7OtnJ4C74utra/ 6Wk5Gyi2o2qqg2xu3CvpLH50rZn76cReDwne9giuZ0g4WQgqTKFr0fY5fLPHg1Dioy1D u/S7S24hdzt0HIZqXjBWMDNvO0vPwKpHUBV/0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=X5lrU/8E0G15fl5MUDsGm3tRUD3gX08jycOMCx8EkPtlXD1kEqFmhsYE0RIZPDfymk Kk1SmhPYGE26+sSL3cOq6nIxH7Co558UB20LRqA3muuBjbL/GHwTNX+ZZtxC7leYdcE+ 7KZ3fODvwKGTXZcsOGP/uUIVtHscDYezhCiyU= MIME-Version: 1.0 Received: by 10.224.111.77 with SMTP id r13mr71046qap.383.1306962924144; Wed, 01 Jun 2011 14:15:24 -0700 (PDT) Received: by 10.224.54.147 with HTTP; Wed, 1 Jun 2011 14:15:24 -0700 (PDT) In-Reply-To: <4DE69D92.5040407@consistentstate.com> References: <4DE69D92.5040407@consistentstate.com> Date: Wed, 1 Jun 2011 16:15:24 -0500 Message-ID: Subject: Re: Problem query From: Merlin Moncure To: CS DBA Cc: pgsql-performance@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.898 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RFC_ABUSE_POST=0.001 X-Spam-Level: X-Archive-Number: 201106/6 X-Sequence-Number: 43939 On Wed, Jun 1, 2011 at 3:14 PM, CS DBA wrote: > Hi All; > > We have a table with approx 200 columns. about a dozen columns are text d= ata > 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=3D1 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 group by tds_= cx_ind, cxs_ind_2 ) > > I've tried to split the query up but made little progress, pri_num and > =A0tds_cx_ind are bigint's and =A0cxs_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? need postgres version# and the current explain analyze (or explain, if you can't wait for it) merlin