X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 7993D9FA65C for ; Tue, 25 Jul 2006 17:48:41 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 92736-09 for ; Tue, 25 Jul 2006 17:48:36 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id 7B6639FA682 for ; Tue, 25 Jul 2006 17:48:36 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 5915930E11; Tue, 25 Jul 2006 22:48:35 +0200 (MET DST) From: "Andrew Hammond" X-Newsgroups: pgsql.performance Subject: Re: Partitioned tables in queries Date: 25 Jul 2006 13:48:28 -0700 Organization: http://groups.google.com Lines: 15 Message-ID: <1153860508.907395.248520@h48g2000cwc.googlegroups.com> References: <44C12852.1040909@borderware.com><44C13909.9050900@borderware.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Complaints-To: groups-abuse@google.com In-Reply-To: <44C13909.9050900@borderware.com> User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.4) Gecko/20060608 Ubuntu/dapper-security Firefox/1.5.0.4,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: h48g2000cwc.googlegroups.com; posting-host=207.219.45.62; posting-account=cSUlcA0AAABWACaPjo2Z9C0GBLTio512 To: pgsql-performance@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.025 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200607/234 X-Sequence-Number: 20094 > 2. I found that using the now() function - and arbitrary interval will > produce a different execution plan that using a specific date. For example: > assuming the current time is 16:00: > a) where start_date > now() - interval '4 hours' scans all child tables. > b) where start_date > '2006-07-21 12:00:00' only scans the child > table with today's data. > > So am I to assume that the value in the query must be a constant, and > cannot be a result of a built-in function in order for > constraint_exclusion to work correctly? Have you tried WHERE start_date > (SELECT now() - interval '4 hours')? Certainly using the constant will allow CBE to work. I think that a subquery might too.