Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 710A29FB8CC for ; Fri, 20 Apr 2007 08:29:36 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 42090-08 for ; Fri, 20 Apr 2007 08:29:32 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.183]) by postgresql.org (Postfix) with ESMTP id BD1019FB89D for ; Fri, 20 Apr 2007 08:29:32 -0300 (ADT) Received: from [194.25.154.138] (helo=webserv.wug.de) by mrelayeu.kundenserver.de (node=mrelayeu7) with ESMTP (Nemesis), id 0ML2xA-1HerIw3FlZ-0007XR; Fri, 20 Apr 2007 13:29:31 +0200 Received: from kretschmer by webserv.wug.de with local (Exim 3.36 #1) id 1HerIw-00072E-00 for pgsql-sql@postgresql.org; Fri, 20 Apr 2007 13:29:30 +0200 Date: Fri, 20 Apr 2007 13:29:30 +0200 From: "A. Kretschmer" To: pgsql-sql@postgresql.org Subject: Re: many 'OR' in WHERE-condition Message-ID: <20070420112930.GE15322@a-kretschmer.de> References: <20070420051341.GA15322@a-kretschmer.de> <46289E10.9060302@archonet.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <46289E10.9060302@archonet.com> X-OS: Debian/GNU Linux - weil ich es mir Wert bin! X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the answer is "no"! User-Agent: Mutt/1.5.9i X-Provags-ID: V01U2FsdGVkX1+7gr/hXSzXjB4h/PaTXOrucddlUvvZTQN9qek hmQNZWmgGchiPLjynREw4z00HtKB/7wliUCusF9k0JB1sAkLgm 0qQOFfnIf9Mcp2wHvPJmiShfWzeU3lF X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/175 X-Sequence-Number: 28175 am Fri, dem 20.04.2007, um 12:03:44 +0100 mailte Richard Huxton folgendes: > 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? It's not my problem - i found it in a forum (german) http://pg-forum.de/showthread.php?t=1332 If the list contains up to 195 entrys -> up to 195 bitmap index scans and BitmapOr -> 7.839ms If the list contains 196 entrys -> seq-scan -> 5591.567ms Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net