Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id A47E363287F for ; Mon, 23 Aug 2010 12:21:16 -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 56927-08 for ; Mon, 23 Aug 2010 15:21:09 +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 89935632629 for ; Mon, 23 Aug 2010 12:21:09 -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 o7NFKtFr021465; Mon, 23 Aug 2010 11:20:56 -0400 (EDT) To: Alvaro Herrera cc: =?utf-8?q?Jann_R=C3=B6der?= , pgsql-performance Subject: Re: Inefficient query plan In-reply-to: <1282574235-sup-6539@alvh.no-ip.org> References: <1282574235-sup-6539@alvh.no-ip.org> Comments: In-reply-to Alvaro Herrera message dated "Mon, 23 Aug 2010 10:38:35 -0400" Date: Mon, 23 Aug 2010 11:20:55 -0400 Message-ID: <21464.1282576855@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: 201008/264 X-Sequence-Number: 40107 Alvaro Herrera writes: > Hmm, I'm placing bets on the bpchar weirdness. I'd try getting rid of > that and using plain varchar for all the columns. That's certainly what's inhibiting it from considering an indexscan on the larger table. I'm not as convinced as the OP that a nestloop indexscan is really going to win compared to the hash plan, but if the comparison value is varchar then an index on a bpchar column is simply not useful --- at least not unless you stick an explicit cast into the query, so that the comparison will have bpchar rather than varchar semantics. regards, tom lane