Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 038889FBA54 for ; Fri, 20 Apr 2007 08:03:50 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 69012-01 for ; Fri, 20 Apr 2007 08:03:41 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id 04D009FB9FD for ; Fri, 20 Apr 2007 08:03:46 -0300 (ADT) Received: from server3.office.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id B9336739BD; Fri, 20 Apr 2007 12:03:44 +0100 (BST) Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id A51782740D7; Fri, 20 Apr 2007 12:03:44 +0100 (BST) Message-ID: <46289E10.9060302@archonet.com> Date: Fri, 20 Apr 2007 12:03:44 +0100 From: Richard Huxton User-Agent: Thunderbird 2.0.0.0 (X11/20070326) MIME-Version: 1.0 To: "A. Kretschmer" Cc: pgsql-sql@postgresql.org Subject: Re: many 'OR' in WHERE-condition References: <20070420051341.GA15322@a-kretschmer.de> In-Reply-To: <20070420051341.GA15322@a-kretschmer.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/172 X-Sequence-Number: 28172 A. Kretschmer wrote: > in a SELECT with a condition 'WHERE foo IN (1,2,3,4,...)' with a large ... > But if the list increase the planner choose an seq-scan. The amount of > values in the list is about 200 and the table has about 250.000 rows. > > How can we avoid the seq-scan? Are you sure you'd want to? What plan have you found to be faster with 200 tests? -- Richard Huxton Archonet Ltd