Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 3CD4A63313A for ; Tue, 27 Jul 2010 17:04:52 -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 89603-08 for ; Tue, 27 Jul 2010 20:04:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ew0-f46.google.com (mail-ew0-f46.google.com [209.85.215.46]) by mail.postgresql.org (Postfix) with ESMTP id DD64E63338C for ; Tue, 27 Jul 2010 17:04:44 -0300 (ADT) Received: by ewy23 with SMTP id 23so1459175ewy.19 for ; Tue, 27 Jul 2010 13:04:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=ARzoE1TxwyDDf6JpsPX1GMvfyI1ZcMNlh6byDt0fEGU=; b=mA0olmJHJNAE6dHsMel+AWFiSpGHV3ZNI2HYT828ljSMMmRoxkilOfVhWe3tEqHLXQ QjsXRSaTSycQvmJgmiRGCjRf4/WOCJzkZsPWBDLFbNZ4lLxAuDCOXRHGCsKkQHVLRz9G s9KtFwclA97xdOnESvmLqyi/FuOXMaU+UqUTs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=smixQAP5eWrfoxUXnEE4ypZi9ScZv1gi2vhI6XdkM1hCW4JcPSHJHtJg6Drctv5yYg ZOdakLdL3W683VMJIUYSO7kCs/BkhfwWut1kmwNJd+lBE41/L51ikRr3/MaQQiXKkqqM MHkyWIcB+1UJtfiVXaYQDy8K+0cdlu87I3Gas= Received: by 10.14.127.196 with SMTP id d44mr1510175eei.27.1280261082956; Tue, 27 Jul 2010 13:04:42 -0700 (PDT) Received: from [0.0.0.0] (5357DA75.cable.casema.nl [83.87.218.117]) by mx.google.com with ESMTPS id z55sm8143451eeh.21.2010.07.27.13.04.42 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 27 Jul 2010 13:04:42 -0700 (PDT) Message-ID: <4C4F3C38.7000006@gmail.com> Date: Tue, 27 Jul 2010 22:06:16 +0200 From: Yeb Havinga User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: Liviu Mirea-Ghiban CC: pgsql-performance@postgresql.org Subject: Re: Slow query using the Cube contrib module. References: <4C4C12D1.70601@gmail.com> In-Reply-To: <4C4C12D1.70601@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201007/413 X-Sequence-Number: 39802 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. See the comments for the 'RECHECK' parameter of CREATE OPERATOR CLASS (http://www.postgresql.org/docs/8.4/static/sql-createopclass.html). Its unwise to alter this behaviour without taking a look/modifying the underlying index implementation. The gist index scann part could perhaps be made a bit faster by using a smaller blocksize, but I'm not sure if or how the recheck part can be improved. Maybe rewriting the top query to not do bitmap heap scans in subqueries or inner loops? regards, Yeb Havinga