Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 0E3749FB659 for ; Wed, 11 Jul 2007 17:04:43 -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 59606-07 for ; Wed, 11 Jul 2007 17:04:31 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 6A16E9FB531 for ; Wed, 11 Jul 2007 17:04:36 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l6BK4Xcl001332; Wed, 11 Jul 2007 16:04:33 -0400 (EDT) To: Andreas Kretschmer cc: pgsql-performance@postgresql.org Subject: Re: bitmap-index-scan slower than normal index scan In-reply-to: <20070711183638.GA30872@KanotixBox> References: <20070711183638.GA30872@KanotixBox> Comments: In-reply-to Andreas Kretschmer message dated "Wed, 11 Jul 2007 20:36:38 +0200" Date: Wed, 11 Jul 2007 16:04:33 -0400 Message-ID: <1331.1184184273@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/120 X-Sequence-Number: 25804 Andreas Kretschmer writes: > Okay, i know, not really a recent version: > PostgreSQL 8.1.4 on i386-pc-linux-gnu, compiled by GCC cc (GCC) 3.3.5 (Debian 1:3.3.5-13) You need a newer one. > -> BitmapAnd (cost=1217.69..1217.69 rows=39 width=0) (actual time=163.681..163.681 rows=0 loops=1) > -> Bitmap Index Scan on idx_ab (cost=0.00..5.95 rows=558 width=0) (actual time=0.078..0.078 rows=109 loops=1) > Index Cond: (ab = 347735) > -> Bitmap Index Scan on idx_maschine (cost=0.00..1211.49 rows=148997 width=0) (actual time=163.459..163.459 rows=164760 loops=1) > Index Cond: (maschine = 1200) This is simply a stupid choice on the part of choose_bitmap_and() --- it's adding on a second index to try to filter on maschine when that scan will actually just increase the cost. I've revisited choose_bitmap_and() a couple times since then; try 8.1.9 and see if it gets this right. Also, part of the problem here looks to be an overestimate of the number of rows matching ab = 347735. It might help to increase the statistics target for that column. regards, tom lane