Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 627389FA2B2 for ; Fri, 20 Apr 2007 08:59:06 -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 49462-03 for ; Fri, 20 Apr 2007 08:59:03 -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 75AA49FB3FF for ; Fri, 20 Apr 2007 08:59:03 -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 B9D1C76109; Fri, 20 Apr 2007 12:59:01 +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 802832740EE; Fri, 20 Apr 2007 12:59:01 +0100 (BST) Message-ID: <4628AB05.6000400@archonet.com> Date: Fri, 20 Apr 2007 12:59:01 +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> <46289E10.9060302@archonet.com> <20070420112930.GE15322@a-kretschmer.de> In-Reply-To: <20070420112930.GE15322@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/176 X-Sequence-Number: 28176 A. Kretschmer wrote: > > 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 It looks like it's getting the row estimate badly wrong. "Seq Scan on t_datasets_searchindices_rel (cost=0.00..129053.50 rows=159277 width=4) (actual time=0.213..5590.435 rows=325 loops=1) Probably worth increasing the statistics estimate for that column (ALTER TABLE ... ALTER COLUMN ... SET STATISTICS=N) It also looks like it's getting the cost estimates badly wrong. Probably worth asking the original poster to read the tuning guide. -- Richard Huxton Archonet Ltd