Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id E5CD99F97F5 for ; Wed, 22 Aug 2007 12:02:19 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 71663-04 for ; Wed, 22 Aug 2007 12:02:17 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from rv-out-0910.google.com (rv-out-0910.google.com [209.85.198.188]) by postgresql.org (Postfix) with ESMTP id 7DB759F9748 for ; Wed, 22 Aug 2007 12:02:16 -0300 (ADT) Received: by rv-out-0910.google.com with SMTP id c24so134264rvf for ; Wed, 22 Aug 2007 08:02:03 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=rLRBlyi8WB/m/AvAGrHwPxuZo7aXMTPtKJZP9+aiLQDCRbaELzwygZd1k6uIg8VtKXimnOU2bvHyzDofPRKXpMtiZ10r0JPc6y/ZpB/FEPxijQ/tDTGRnK/7NgHSa7pEM1m8mIpOilYG5gK19foPcRuoXWyx3xdG038WcvW8WRk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=UmcUSSQr/qPhjOkI/BI+b8m/jDh6gMYHa/dU8hatUwrFLYBobX1Cie7/LsrNlFrkBvtOj8nYZlEarl1SYEM6ux463uqYBojkj1Q28LUyJUuF0/+Bfn8IpdpBeauYtUGKvKn1eUbF0X96ms8AnvMDEM3+DUife1EtKPqGLhORtw4= Received: by 10.141.83.15 with SMTP id k15mr338310rvl.1187794923600; Wed, 22 Aug 2007 08:02:03 -0700 (PDT) Received: by 10.140.194.12 with HTTP; Wed, 22 Aug 2007 08:02:03 -0700 (PDT) Message-ID: Date: Wed, 22 Aug 2007 19:02:03 +0400 From: "Aleksandr Vinokurov" To: "Scott Marlowe" Subject: Re: Partial index and query plan Cc: pgsql-sql@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/199 X-Sequence-Number: 29137 Scott Marlowe wrote: > > I don't see the issue here. The index being used is the same partial > index you created. Maybe it's just a question of semantics? > As I understand final filter is: a) pointed at the index creation b) is redundant as all the indexed records have action <> 0. So checking of it is a time wasting. And the plan should be this: >> Limit (cost=0.00..3.05 rows=1 width=8) (actual time=4.798..4.798 >> rows=0 loops=1) >> -> Index Scan using indx_date_action12_uid_user_his on >> user_history (cost=0.00..6.10 rows=2 width=8) (actual >> time=4.791..4.791 rows=0 loops=1) >> Index Cond: ((date > '2007-08-18 14:33:40.60664'::timestamp >> without time zone) AND (date <= '2007-08-18 16:30:00'::timestamp >> without time zone) AND (uid = 138658)) I suggest that this 'Filter' check will not be noticed as it always return TRUE, and so will be checked only once, -- because of the "limit 1". :) But thanks, Aleksandr.