X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B9B3D5E3639 for ; Fri, 20 Aug 2004 13:49:59 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 94716-07 for ; Fri, 20 Aug 2004 16:50:04 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id A518C5E3632 for ; Fri, 20 Aug 2004 13:49:56 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7KGo11b027337; Fri, 20 Aug 2004 12:50:02 -0400 (EDT) To: Bruno Wolff III Cc: Danilo Mota , pgsql-performance@postgresql.org Subject: Re: Query performance problem In-reply-to: <20040820164821.GA26674@wolff.to> References: <002201c486d2$4fbe4420$8afea8c0@nexen.lan> <20040820164821.GA26674@wolff.to> Comments: In-reply-to Bruno Wolff III message dated "Fri, 20 Aug 2004 11:48:21 -0500" Date: Fri, 20 Aug 2004 12:50:01 -0400 Message-ID: <27336.1093020601@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/307 X-Sequence-Number: 7943 Bruno Wolff III writes: > I am going to assume that one of the sc.cpfcnpj's above is really rc.cpfcnpj > since that corresponds to the explain below. No, actually the explain plan corresponds to the sc.cpfcnpj = sc.cpfcnpj condition. I didn't twig to the typo until I started to wonder why the plan had the condition in the wrong place (attached to the seqscan and not the join step). > sc.cpfcnpj and rc.cpfcnpj are different length varchars. You made need > an explicit cast to allow the use of indexes. AFAIK the cross-type issues only apply to crossing actual types, not lengths. That does look like an error in the database schema, though. regards, tom lane