Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wf9Lm-0004xk-6J for pgsql-bugs@arkaria.postgresql.org; Tue, 29 Apr 2014 14:49:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Wf9Ll-0002vQ-Kq for pgsql-bugs@arkaria.postgresql.org; Tue, 29 Apr 2014 14:49:37 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wf9Lj-0002th-Tx for pgsql-bugs@postgresql.org; Tue, 29 Apr 2014 14:49:36 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wf9Lc-0005n0-3r for pgsql-bugs@postgresql.org; Tue, 29 Apr 2014 14:49:35 +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 s3TEnRak017574; Tue, 29 Apr 2014 10:49:27 -0400 From: Tom Lane To: pilum.70@uni-muenster.de cc: pgsql-bugs@postgresql.org Subject: Re: BUG #10171: Specific prepared statement cannot use bitmapOr index scan since 9.2 In-reply-to: <20140429074155.2644.29021@wrigleys.postgresql.org> References: <20140429074155.2644.29021@wrigleys.postgresql.org> Comments: In-reply-to pilum.70@uni-muenster.de message dated "Tue, 29 Apr 2014 07:41:55 -0000" Date: Tue, 29 Apr 2014 10:49:27 -0400 Message-ID: <17573.1398782967@sss.pgh.pa.us> X-Pg-Spam-Score: -2.6 (--) 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 pilum.70@uni-muenster.de writes: > The following query uses bitmap or index scan in 9.1, but only Nested Loop > in 9.2 and 9.3: Interesting. The plan actually gets stupider when it has values for the parameters, if those values chance to be NULL. The reason seems to be that after substituting the parameters and constant-folding, we've got this join condition: (t1.id2 = ''::text AND t2.id2 = ''::text) OR NULL::boolean and the code in orclause.c is unable to realize that it can extract the sub-AND elements as restriction clauses for t1 and t2. But it'd be all right to ignore the constant-null OR arm, since that can't possibly succeed. Another way of looking at this is that we should be smart enough to throw away the constant-null OR arm altogether at top level of WHERE, since at top level we don't particularly care whether the OR produces FALSE or NULL if all its other inputs are FALSE. That would probably be a more general fix. I'll see what I can do about this. Thanks for the report! 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