Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id AF9909FA344 for ; Tue, 21 Nov 2006 11:44:25 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 10968-09 for ; Tue, 21 Nov 2006 15:44:16 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 515569FA333 for ; Tue, 21 Nov 2006 11:44:16 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id kALFiDt1004623; Tue, 21 Nov 2006 10:44:13 -0500 (EST) To: =?ISO-8859-1?Q?J=E9r=F4me?= BENOIS cc: PostgreSQL Performance , Xavier Milliard , Laurent BELMONTE Subject: Re: BitMapScan performance degradation In-reply-to: <1164100889.5281.184.camel@localhost.localdomain> References: <1164100889.5281.184.camel@localhost.localdomain> Comments: In-reply-to =?ISO-8859-1?Q?J=E9r=F4me?= BENOIS message dated "Tue, 21 Nov 2006 10:21:29 +0100" Date: Tue, 21 Nov 2006 10:44:13 -0500 Message-ID: <4622.1164123853@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/173 X-Sequence-Number: 21943 =?ISO-8859-1?Q?J=E9r=F4me?= BENOIS writes: > You can read two results of EXPLAIN ANALYZE command here : > http://sharengo.org/explain.txt I think the problem is the misestimation of the size of the reqin3 result: -> Bitmap Heap Scan on mpng2_ei_attribute reqin3 (cost=28.17..32.18 rows=1 width=4) (actual time=1.512..7.941 rows=1394 loops=1) Recheck Cond: (((string_value)::text = '1084520156'::text) AND ((name)::text = 'CategoryID-1084520156'::text)) -> BitmapAnd (cost=28.17..28.17 rows=1 width=0) (actual time=1.275..1.275 rows=0 loops=1) -> Bitmap Index Scan on mpng2_ei_attribute_string_value (cost=0.00..4.78 rows=510 width=0) (actual time=0.534..0.534 rows=1394 loops=1) Index Cond: ((string_value)::text = '1084520156'::text) -> Bitmap Index Scan on mpng2_ei_attribute_name (cost=0.00..23.13 rows=2896 width=0) (actual time=0.590..0.590 rows=1394 loops=1) Index Cond: ((name)::text = 'CategoryID-1084520156'::text) Anytime a rowcount estimate is off by more than a factor of a thousand, you can expect some poor choices in the rest of the plan :-(. It looks to me like the planner is expecting those two index conditions to be independently selective, when in reality they are completely redundant. Perhaps rethinking your data model would be a useful activity. regards, tom lane