Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id A982A632EE0 for ; Tue, 27 Jul 2010 19:19:00 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 50774-08 for ; Tue, 27 Jul 2010 22:18:52 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 5B949632C47 for ; Tue, 27 Jul 2010 19:18:53 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o6RMIorQ016995; Tue, 27 Jul 2010 18:18:50 -0400 (EDT) To: Yeb Havinga cc: Liviu Mirea-Ghiban , pgsql-performance@postgresql.org Subject: Re: Slow query using the Cube contrib module. In-reply-to: <4C4F3C38.7000006@gmail.com> References: <4C4C12D1.70601@gmail.com> <4C4F3C38.7000006@gmail.com> Comments: In-reply-to Yeb Havinga message dated "Tue, 27 Jul 2010 22:06:16 +0200" Date: Tue, 27 Jul 2010 18:18:50 -0400 Message-ID: <16994.1280269130@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201007/416 X-Sequence-Number: 39805 Yeb Havinga writes: > Liviu Mirea-Ghiban wrote: >> My question is: Why is it doing a Bitmap Heap Scan / Recheck Cond? >> I've executed dozens of such queries and not once did the rechecking >> remove any rows. Is there any way to disable it, or do you have any >> other suggestions for optimizations (because I'm all out of ideas)? > It's probably because the index nodes store data values with a lossy > compression, which means that the index scan returns more rows than > wanted, and that in turn is filtered out by the rescanning. The recheck expression is only executed if the index reports that it's not executed the search exactly. If you don't see any difference between the indexscan and bitmapscan output counts, it's probably because the index can do the case exactly, so the recheck expression isn't really getting used. The planner has to include the expression in the plan anyway, because the decision about lossiness is not known until runtime. But it's not costing any runtime. The OP is mistaken to think there's anything wrong with this plan choice ---- more than likely, it's the best available plan. The reason there's a significant gap between the indexscan runtime and the bitmapscan runtime is that that's the cost of going and actually fetching all those rows from the table. The only way to fix that is to buy a faster disk or get more RAM so that more of the table can be held in memory. regards, tom lane