Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 7ECE0632288 for ; Tue, 22 Jun 2010 23:02:04 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 10749-07 for ; Wed, 23 Jun 2010 02:01:55 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 590A46321AE for ; Tue, 22 Jun 2010 23:01:57 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o5N21rbV011813; Tue, 22 Jun 2010 22:01:53 -0400 (EDT) To: Alvaro Herrera cc: Anj Adu , pgsql-performance Subject: Re: slow index lookup In-reply-to: <1277250226-sup-6686@alvh.no-ip.org> References: <1277250226-sup-6686@alvh.no-ip.org> Comments: In-reply-to Alvaro Herrera message dated "Tue, 22 Jun 2010 19:44:15 -0400" Date: Tue, 22 Jun 2010 22:01:53 -0400 Message-ID: <11812.1277258513@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201006/385 X-Sequence-Number: 39241 Alvaro Herrera writes: > Excerpts from Anj Adu's message of mar jun 22 17:44:39 -0400 2010: >> This query seems unreasonable slow on a well-indexed table (13 million >> rows). Separate indexes are present on guardid_id , from_num and >> targetprt columns. > Maybe you need to vacuum or reindex? Rethinking the set of indexes is probably a more appropriate suggestion. Separate indexes aren't usefully combinable for a case like this --- in principle the thing could do a BitmapAnd, but the startup time would be pretty horrid, and the LIMIT 1 is discouraging it from trying that. If this is an important case to optimize then you need a 3-column index. regards, tom lane