Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UsH9Q-00082H-I4 for pgsql-performance@arkaria.postgresql.org; Thu, 27 Jun 2013 18:42:36 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1UsH9Q-0001yk-1R for pgsql-performance@arkaria.postgresql.org; Thu, 27 Jun 2013 18:42:36 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UsH9O-0001yd-L8 for pgsql-performance@postgresql.org; Thu, 27 Jun 2013 18:42:34 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UsH9I-0005Qr-Ao for pgsql-performance@postgresql.org; Thu, 27 Jun 2013 18:42:34 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id r5RIgQpS027534; Thu, 27 Jun 2013 14:42:26 -0400 (EDT) From: Tom Lane To: sthomas@optionshouse.com cc: Dave Johansen , bricklen , "pgsql-performance@postgresql.org" Subject: Re: Partitions not Working as Expected In-reply-to: <51CC8160.2080905@optionshouse.com> References: <51CC652F.3010304@optionshouse.com> <51CC73B6.2050406@optionshouse.com> <51CC8160.2080905@optionshouse.com> Comments: In-reply-to Shaun Thomas message dated "Thu, 27 Jun 2013 13:16:00 -0500" Date: Thu, 27 Jun 2013 14:42:26 -0400 Message-ID: <27533.1372358546@sss.pgh.pa.us> X-Pg-Spam-Score: -0.5 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Shaun Thomas writes: > On 06/27/2013 12:42 PM, Dave Johansen wrote: >> Or what about something like DATE_TRUNC("DAY", now())? Or would that run >> into the same optimization/planner problems as CURRENT_DATE? > Same issue. This seems to work, though I'm not entirely sure of the > implications: > UPDATE pg_proc > SET provolatile = 'i' > WHERE proname = 'date_in'; That will break things: CURRENT_DATE will then be equivalent to just writing today's date as a literal. It's conceivable that it wouldn't break any scenario that you personally care about, if you never use CURRENT_DATE in any view, rule, column default expression, or cached plan; but it seems mighty risky from here. I don't see any very good solution to your problem within the current approach to partitioning, which is basically theorem-proving. That proof engine has no concept of time passing, let alone the sort of detailed knowledge of the semantics of this particular function that would allow it to conclude "if CURRENT_DATE > '2013-06-20' is true now, it will always be so in the future as well". I think most hackers agree that the way forward on partitioning involves building hard-wired logic that selects the correct partition(s) at run-time, so that it wouldn't particularly matter where we got the comparison value from or whether it was a constant. So I'm not feeling motivated to try to hack some solution for this case into the theorem prover. Unfortunately, it's likely to be awhile before that next-generation partitioning code shows up. But major extensions to the proof engine wouldn't be a weekend project, either... regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance