Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YR1Qg-0003Uh-D1 for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Feb 2015 16:36:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YR1Qf-0001iG-QN for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Feb 2015 16:36:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YR1Qd-0001fb-QW for pgsql-hackers@postgresql.org; Thu, 26 Feb 2015 16:36:47 +0000 Received: from mail-wg0-f48.google.com ([74.125.82.48]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YR1QZ-0006Ok-4W for pgsql-hackers@postgresql.org; Thu, 26 Feb 2015 16:36:46 +0000 Received: by wghl2 with SMTP id l2so12579430wgh.9 for ; Thu, 26 Feb 2015 08:36:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:organization:user-agent :mime-version:to:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=spnH9gn4ikMKjzjgvTpiMXGRc+/34qkH69qDbJj/7dA=; b=RSsu8S2OSBK70lGEPuT07JO9v5TqV7IHWp+6eB5aKedTkVtNoc3VZAscp0XZDSErc9 0JDc5/4isxrpQxw/6fXgQGGOGHPifQX0MVphJjVmiXbqneqwRYFpcXlC0GUE+ykI+sF7 HSuYikj5nYILSMz2T5NN6UK0HwRflFO5bbebo4D3SSj0fHW3wUR7+IynlVoUTsyRCnyN JdZ8bUK2jMFwLI3udBAC//gTN8HMxInm38f3ziSE4IFql2D3SPFmce0fP4xzduyHISHc 1aDKWeya7oY3xsClNBuF08zXMQjWvbkUBu4cF980hr8uRs0ry7oT9VgxQGvO+mqofUSF utpg== X-Gm-Message-State: ALoCoQnylJgLiZ3M62h7aOzVEEYDU7ESndv7iFmFgdUGQsokloqlkXcX9EQnqpHZpotNghJ3cTNQ7T1FJlhwtrA7k1QiOcNczTdt2dpDyUOAxcUt/MbOL8Ltk3T2nkrMcHtR3pH4cn/yg8xbCDiRyGDpo2Q1TqIWrwHSGPTPly7bHujyos0y0H3K8PUsZ6s6g0CpHlTgsB4z X-Received: by 10.194.142.205 with SMTP id ry13mr18825458wjb.73.1424968601428; Thu, 26 Feb 2015 08:36:41 -0800 (PST) Received: from [192.168.1.163] (ip-78-45-139-138.net.upcbroadband.cz. [78.45.139.138]) by mx.google.com with ESMTPSA id v16sm30598652wib.5.2015.02.26.08.36.40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Feb 2015 08:36:40 -0800 (PST) Message-ID: <54EF4B80.7020902@2ndquadrant.com> Date: Thu, 26 Feb 2015 17:36:16 +0100 From: Tomas Vondra Organization: 2ndQuadrant User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: David Rowley , PostgreSQL-development Subject: Re: Performance improvement for joins where outer side is unique References: <54EE659F.8050004@2ndquadrant.com> In-Reply-To: <54EE659F.8050004@2ndquadrant.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 26.2.2015 01:15, Tomas Vondra wrote: > > I'm not quite sure why, but eclassjoin_is_unique_join() never actually > jumps into this part (line ~400): > > if (relvar != NULL && candidaterelvar != NULL) > { > ... > index_vars = lappend(index_vars, candidaterelvar); > ... > } > > so the index_vars is NIL. Not sure why, but I'm sure you'll spot the > issue right away. FWIW this apparently happens because the code only expect that EquivalenceMembers only contain Var, but in this particular case that's not the case - it contains RelabelType (because oprcode is regproc, and needs to be relabeled to oid). Adding this before the IsA(var, Var) check fixes the issue if (IsA(var, RelabelType)) var = (Var*) ((RelabelType *) var)->arg; but this makes the code even more confusing, because 'var' suggests it's a Var node, but it's RelabelType node. Also, specialjoin_is_unique_join() may have the same problem, but I've been unable to come up with an example. regards -- Tomas Vondra http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers