Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1USq3a-00032H-JT for pgsql-performance@arkaria.postgresql.org; Thu, 18 Apr 2013 14:43:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1USq3a-0008Pj-48 for pgsql-performance@arkaria.postgresql.org; Thu, 18 Apr 2013 14:43:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1USq3Z-0008Pe-Df for pgsql-performance@postgresql.org; Thu, 18 Apr 2013 14:43:25 +0000 Received: from archon2012.plus.com ([80.229.41.160] helo=mail.archonet.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1USq3W-0003AU-Gh for pgsql-performance@postgresql.org; Thu, 18 Apr 2013 14:43:25 +0000 Received: from [192.168.1.13] (ariel.office.archonet.com [192.168.1.13]) by mail.archonet.com (Postfix) with ESMTP id 8C45E2C0268; Thu, 18 Apr 2013 15:43:20 +0100 (BST) Message-ID: <51700688.4050505@archonet.com> Date: Thu, 18 Apr 2013 15:43:20 +0100 From: Richard Huxton User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 MIME-Version: 1.0 To: dmitry potapov CC: pgsql-performance@postgresql.org Subject: Re: "WHERE 1 = 2 OR ..." makes planner choose a very inefficient plan References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 18/04/13 15:20, dmitry potapov wrote: > Hello, > > I recently stumbled upon on what could be a planner bug or a corner > case. If " OR ..." is added to WHERE clause of SELECT > query, then the planner chooses a very inefficient plan. Consider a query: > If I comment out "1=2 OR", then the plan changes dramatically: What happens if you substitute: 1. 1=3 OR 2. false OR -- Richard Huxton Archonet Ltd -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance