Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XhNho-0000cE-Jf for pgsql-bugs@arkaria.postgresql.org; Thu, 23 Oct 2014 19:05:52 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XhNhn-0005xe-VP for pgsql-bugs@arkaria.postgresql.org; Thu, 23 Oct 2014 19:05:52 +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 1XhNhn-0005xX-07 for pgsql-bugs@postgresql.org; Thu, 23 Oct 2014 19:05:51 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XhNhj-0000UA-G3 for pgsql-bugs@postgresql.org; Thu, 23 Oct 2014 19:05:49 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s9NJ5fQq011166; Thu, 23 Oct 2014 15:05:41 -0400 From: Tom Lane To: chocholousp@avast.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #11771: wrong behaviour of planner when pushing conditions In-reply-to: <20141023153816.2676.95359@wrigleys.postgresql.org> References: <20141023153816.2676.95359@wrigleys.postgresql.org> Comments: In-reply-to chocholousp@avast.com message dated "Thu, 23 Oct 2014 15:38:16 -0000" Date: Thu, 23 Oct 2014 15:05:41 -0400 Message-ID: <11165.1414091141@sss.pgh.pa.us> X-Pg-Spam-Score: -3.3 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org chocholousp@avast.com writes: > wrong behaviour of planner when pushing conditions from outer query to > subselect There's nothing wrong with what the planner did here. There is no constraint on reordering the application of WHERE clauses with an inner join --- if there were, it'd be catastrophic to performance in many real queries. In the particular case at hand, what's actually happening is that the two equalities t.t::uuid = x.t::uuid x.t::uuid = '88652f64-6cca-4ffa-a756-000007406ba6'::uuid get reassociated into t.t::uuid = '88652f64-6cca-4ffa-a756-000007406ba6'::uuid x.t::uuid = '88652f64-6cca-4ffa-a756-000007406ba6'::uuid so that the condition on t.t isn't a join condition at all and can get applied to the (unprotected) scan of t. So the condition in the subselect has nothing to do with whether a failure occurs. However, even without that, you would have had failures when the join condition was applied, because the fact that x.t can validly be cast to a uuid doesn't imply that every t.t value it could be compared to can be cast to uuid. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs