Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YR2YZ-0007ji-DP for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Feb 2015 17:49:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YR2YY-0004oL-QZ for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Feb 2015 17:49:02 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YR2YW-0004kl-71 for pgsql-hackers@postgresql.org; Thu, 26 Feb 2015 17:49:00 +0000 Received: from mail-wg0-f45.google.com ([74.125.82.45]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YR2YS-0007Km-Ai for pgsql-hackers@postgresql.org; Thu, 26 Feb 2015 17:48:58 +0000 Received: by wghl18 with SMTP id l18so13223392wgh.8 for ; Thu, 26 Feb 2015 09:48:54 -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:cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=oYRj2Ay9ewC3k8AoQWVCwGHrviJ5LJZ8XTwqchR/Ujw=; b=fknZQVGa7wcohuLIEmIj+w2fJU946HPDEH9isE9uyWXy0+wdsFTFts5eULmfBJlIgI EbaMXd/9tNIjuRWvlYe66Pr/KlAzagasOQTQem+4Iv5SnopM9RL76XfvcrA1Gw1jw6RV 0QXeNroqBDSa9YuWLQjakS/xVzfI56kr7q3tu+mY8t1f/o9D+3cLy/vUHF+404K4+biF pVgjA5pWj3s/QO5zkjdXI3Aiwdqf2zYHlup+g5LOsdrK+Q+Ghb9aIfZfskYxI3UBc0G+ A7gQVjsGDGAxkM4uAcXfNdKKL+eMHvlBocSX8y1PmtRdCyIeuH8W/Yb/4LnNg55qy2Lc h+Bw== X-Gm-Message-State: ALoCoQmjWZntbtc7gvgRBTqljTwTXRvINYmlGmtPrzccUZ4/fnBCcTBh1HWAvePjSyJijuI5+Ae4D4s3o/RfMalEjT4wvUa6vv5Mz7p7/Jdf7C5X2yPA2goVtu6bgK2YpEqtDR36FzdFCUTTlIjvE0oD9zzuv5RhOsTTkRT6mhJzqBiUYZsukx8PV3JemrNwl1m6tTUwkaxJ X-Received: by 10.194.78.72 with SMTP id z8mr19755542wjw.0.1424972933570; Thu, 26 Feb 2015 09:48:53 -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 fs8sm30858905wib.8.2015.02.26.09.48.52 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Feb 2015 09:48:52 -0800 (PST) Message-ID: <54EF5C6C.6030001@2ndquadrant.com> Date: Thu, 26 Feb 2015 18:48:28 +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: Tom Lane CC: David Rowley , PostgreSQL-development Subject: Re: Performance improvement for joins where outer side is unique References: <54EE659F.8050004@2ndquadrant.com> <54EF4B80.7020902@2ndquadrant.com> <12606.1424972064@sss.pgh.pa.us> In-Reply-To: <12606.1424972064@sss.pgh.pa.us> Content-Type: text/plain; charset=iso-8859-2 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 18:34, Tom Lane wrote: > Tomas Vondra writes: >> 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). > > If it thinks an EquivalenceMember must be a Var, it's outright > broken; I'm pretty sure any nonvolatile expression is possible. I came to the same conclusion, because even with the RelabelType fix it's trivial to crash it with a query like this: SELECT 1 FROM pg_proc p JOIN pg_operator o ON oprcode = (p.oid::int4 + 1); I think fixing this (e.g. by restricting the optimization to Var-only cases) should not be difficult, although it might be nice to handle generic expressions too, and something like examine_variable() should do the trick. But I think UNIQUE indexes on expressions are not all that common. -- 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