Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id D04322E004A for ; Wed, 9 Apr 2008 19:17:42 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 53435-04 for ; Wed, 9 Apr 2008 19:17:40 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from wf-out-1314.google.com (wf-out-1314.google.com [209.85.200.169]) by developer.postgresql.org (Postfix) with ESMTP id 3E7252E0047 for ; Wed, 9 Apr 2008 19:17:40 -0300 (ADT) Received: by wf-out-1314.google.com with SMTP id 28so2665365wff.28 for ; Wed, 09 Apr 2008 15:17:38 -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:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=w98kkbKQj/3Zg1a6Vqvt0yHBKtZqmaREwYy2ai0u0xs=; b=rTKH3QJNXCDqythc7sVfxS4SbbY76Zf2A4MBCgfag+wN11yGR48fDK4BCfyPEVKrk2AkH7AZPq+XcerIENIont/QsUm4m6HyVkkxHWzwWapHvVcdbcwIuRVoTMy0kzB776tBNOVNkDdYYImnRuUpMNTnET6dFjY/u7WJW9CPib0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=V8j2qeTt43ujr9FMTvw2umplo5ZScIgCHPdPy7wtucIw+fC1Ts0rWI6zNy3g6GR0kBjmDZCHo0Zohwhm5WUQGzVbRFmfWAC0oXJZhQBfQUsUU/4X7mF5RLlK5WND91VkOHYOy1tjeqYlH1xSq7jiI/gXXV3t3M0tc2XDTLbx7ss= Received: by 10.143.42.3 with SMTP id u3mr199305wfj.148.1207779458858; Wed, 09 Apr 2008 15:17:38 -0700 (PDT) Received: by 10.142.144.1 with HTTP; Wed, 9 Apr 2008 15:17:38 -0700 (PDT) Message-ID: <396486430804091517s1b99843cs10e812c0722f191b@mail.gmail.com> Date: Wed, 9 Apr 2008 15:17:38 -0700 From: "Richard Broersma" To: PFC Subject: Re: EXPLAIN detail Cc: "Luigi N. Puleio" , "Craig Ringer" , pgsql-performance@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: <981759.47577.qm@web33504.mail.mud.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/115 X-Sequence-Number: 29608 On Wed, Apr 9, 2008 at 11:41 AM, PFC wrote: > In order to use the index, you could rewrite it as something like : > a.calldate >= '2008-04-09' AND a.calldate < ('2008-04-09'::DATE + '1 > DAY'::INTERVAL) > This is a RANGE query (just like BETWEEN) which is index-friendly. Another option would be to create a functional index on date_trunc( 'day', cdr.calldate) then using a where condition like: date_trunc(a.calldate) = '2008-04-09' would definitely use an index. -- Regards, Richard Broersma Jr.