Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UsJ2V-0005HX-JO for pgsql-performance@arkaria.postgresql.org; Thu, 27 Jun 2013 20:43:35 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1UsJ2V-0008NU-0c for pgsql-performance@arkaria.postgresql.org; Thu, 27 Jun 2013 20:43:35 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UsJ2U-0008NO-5G for pgsql-performance@postgresql.org; Thu, 27 Jun 2013 20:43:34 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UsJ2R-0007dr-9b for pgsql-performance@postgresql.org; Thu, 27 Jun 2013 20:43:33 +0000 Received: from intern.anarazel.de (p549F33F4.dip0.t-ipconnect.de [84.159.51.244]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id AFDA05E005A; Thu, 27 Jun 2013 22:43:19 +0200 (CEST) Date: Thu, 27 Jun 2013 22:43:17 +0200 From: Andres Freund To: Tom Lane Cc: sthomas@optionshouse.com, Dave Johansen , bricklen , "pgsql-performance@postgresql.org" Subject: Re: Partitions not Working as Expected Message-ID: <20130627204317.GP1254@alap2.anarazel.de> References: <51CC652F.3010304@optionshouse.com> <51CC73B6.2050406@optionshouse.com> <51CC8160.2080905@optionshouse.com> <27533.1372358546@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <27533.1372358546@sss.pgh.pa.us> X-Pg-Spam-Score: 0.1 (/) 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 On 2013-06-27 14:42:26 -0400, Tom Lane wrote: > 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". Couldn't we at least significantly improve on the status quo by detecting we're currently planning a query that's only going to be executed once (because it's directly executed or because were planning a onetime plan for specific parameters) and inline stable functions before doing the theorem proving? Maybe I am missing something here? Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance