X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 083B79FA0EC for ; Wed, 5 Jul 2006 03:56:22 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 18554-04-2 for ; Wed, 5 Jul 2006 03:56:13 -0300 (ADT) X-Greylist: delayed 00:28:01.463307 by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 8929A9FA634 for ; Wed, 5 Jul 2006 03:56:13 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from tenar.csd.uoc.gr (tenar.csd.uoc.gr [147.52.16.3]) by svr4.postgresql.org (Postfix) with ESMTP id 61AF95AF07D for ; Wed, 5 Jul 2006 06:28:10 +0000 (GMT) Received: from localhost (ermis.edu.uoc.gr [147.52.78.6]) by tenar.csd.uoc.gr (8.12.11.20060308/8.12.10) with ESMTP id k656QHG5002506 for ; Wed, 5 Jul 2006 09:26:17 +0300 (EEST) Organization: Received: from hera530-a101.otenet.gr (hera530-a101.otenet.gr [212.205.208.101]) by ermis.edu.uoc.gr (IMP) with HTTP for ; Wed, 5 Jul 2006 08:54:44 +0300 Message-ID: <1152078884.44ab542441450@ermis.edu.uoc.gr> Date: Wed, 5 Jul 2006 08:54:44 +0300 From: jkapad@csd.uoc.gr To: pgsql-performance@postgresql.org Subject: Problem with bitmap-index-scan plan MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-7 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.2 X-Originating-IP: 212.205.208.101 X-Scanned-By: MIMEDefang 2.56 on 147.52.16.3 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/22 X-Sequence-Number: 19882 Hi, If I run the query explain analyze select * from ind_uni_100 where a=1 and b=1 and c=1 I get the following plan: Bitmap Heap Scan on ind_uni_100 (cost=942.50..1411.12 rows=125 width=104) (actual time=72.556..72.934 rows=116 loops=1) Recheck Cond: ((c = 1) AND (a = 1) AND (b = 1)) -> BitmapAnd (cost=942.50..942.50 rows=125 width=0) (actual time=72.421..72.421 rows=0 loops=1) -> Bitmap Index Scan on index_c_ind_uni_100 (cost=0.00..314.00 rows=50000 width=0) (actual time=21.854..21.854 rows=49832 loops=1) Index Cond: (c = 1) -> Bitmap Index Scan on index_a_ind_uni_100 (cost=0.00..314.00 rows=50000 width=0) (actual time=22.371..22.371 rows=50319 loops=1) Index Cond: (a = 1) -> Bitmap Index Scan on index_b_ind_uni_100 (cost=0.00..314.00 rows=50000 width=0) (actual time=14.226..14.226 rows=49758 loops=1) Index Cond: (b = 1) Total runtime: 73.395 ms Which is quite reasonable.The table has 1.000.000 rows (17.242 pages). From pg_stat_get_blocks_fetched I can see that there were 102 page requests for table. So all things seem to work great here! But if I multiply the size of the table ten-times (10.000.000 rows - 172.414 pages) and run the same query I get: explain analyze select * from ind_uni_1000 where a=1 and b=1 and c=1 Bitmap Heap Scan on ind_uni_1000 (cost=9369.50..14055.74 rows=1250 width=104) (actual time=18111.415..176747.937 rows=1251 loops=1) Recheck Cond: ((c = 1) AND (a = 1) AND (b = 1)) -> BitmapAnd (cost=9369.50..9369.50 rows=1250 width=0) (actual time=17684.587..17684.587 rows=0 loops=1) -> Bitmap Index Scan on index_c_ind_uni_1000 (cost=0.00..3123.00 rows=500000 width=0) (actual time=5704.624..5704.624 rows=500910 loops=1) Index Cond: (c = 1) -> Bitmap Index Scan on index_a_ind_uni_1000 (cost=0.00..3123.00 rows=500000 width=0) (actual time=6147.962..6147.962 rows=500080 loops=1) Index Cond: (a = 1) -> Bitmap Index Scan on index_b_ind_uni_1000 (cost=0.00..3123.00 rows=500000 width=0) (actual time=5767.754..5767.754 rows=500329 loops=1) Index Cond: (b = 1) Total runtime: 176753.200 ms which is slower even than a seq scan. Now I get that there were 131.398 page requests for table in order to retrieve almost 1250 tuples!Can someone explain why this is happening? All memory parameters are set to default. Thanks!