Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UsHeT-0001Ak-FJ for pgsql-performance@arkaria.postgresql.org; Thu, 27 Jun 2013 19:14:41 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1UsHeS-0002lP-UW for pgsql-performance@arkaria.postgresql.org; Thu, 27 Jun 2013 19:14:40 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UsHeR-0002jR-Nl for pgsql-performance@postgresql.org; Thu, 27 Jun 2013 19:14:39 +0000 Received: from smtp2.peak6.com ([38.98.137.9]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UsHeO-00060s-Mp for pgsql-performance@postgresql.org; Thu, 27 Jun 2013 19:14:38 +0000 X-AuditID: 0a02cb20-b7f216d000002f75-73-51cc8f1a6cda Received: from sswchi5pcas2.peak6.net (Unknown_Domain [10.100.13.24]) by smtp2.peak6.com (Symantec Messaging Gateway) with SMTP id 96.C8.12149.A1F8CC15; Thu, 27 Jun 2013 14:14:35 -0500 (CDT) Received: from [10.10.201.64] (10.10.201.64) by sswchi5pcas2.peak6.net (10.100.13.25) with Microsoft SMTP Server (TLS) id 14.3.123.3; Thu, 27 Jun 2013 14:14:34 -0500 Message-ID: <51CC8F1A.1090805@optionshouse.com> Date: Thu, 27 Jun 2013 14:14:34 -0500 From: Shaun Thomas Reply-To: Organization: Peak6 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: Tom Lane CC: Dave Johansen , bricklen , "pgsql-performance@postgresql.org" Subject: Re: Partitions not Working as Expected References: <51CC652F.3010304@optionshouse.com> <51CC73B6.2050406@optionshouse.com> <51CC8160.2080905@optionshouse.com> <27533.1372358546@sss.pgh.pa.us> In-Reply-To: <27533.1372358546@sss.pgh.pa.us> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed content-transfer-encoding: 7bit X-Originating-IP: [10.10.201.64] X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHKsWRmVeSWpSXmKPExsXClcIroSvdfybQYPNMRov1Hw+yWvxv+8No cX3mOWaLU6vuMjmweOycdZfd48K+aewei55tZAlgjmpgtEnMy8svSSxJVUhJLU62VfIvKMnM zyv2yC8tTlVwySxOzknMzE0tUlLITLFVMlZSKMhJTE7NTc0rsVVKLChIzUtRsuNSwAA2QGWZ eQqpecn5KZl56bZKnsH+uhYWppa6hkp28cggoZMl49LUJ2wFh4Uq5jzZytrA+Iivi5GDQ0LA RKLzonYXIyeQKSZx4d56NhBbSOAAo8SM9yJdjFxA9kpGiXdtzewgCV4BfYmlc7rBilgEVCWm 71zNCmKzCehKTOpfAdWsItF39gYTiM0vICyx70MTM4gtKhAm8X7ZVFaIOYISJ2c+YQGxRQQU JPoevGMHWcYsMIlR4mVrFyNIQljAUuLa8i0sEFc8Y5LYs+EiI8jVnEDb/m3UA6lhFrCVuDDn OguELS+x/e0cZogjVCVWNE9kg/hMQeL/lXdMExhFZiHZPQtJ+ywk7QsYmVcxiheXJSZnZJoV FOeWFBjpFaQmZpvp5aWWbGIEJQKm0wo7GDf3WB1iFOBgVOLhnZB/JlCINbGsuDL3EKMEB7OS CO8Rf6AQb0piZVVqUX58UWlOavEhRh9goE1klhJNzgcmqbySeENjUwNTS1NDU3NTQyMcwkri vPuYlgUKCaQDk092ampBahHMOCYOTqkGxrWHnMsmi7r/kFqyyEf9Y8PFjTISa//uqZgwTzZe vXH/yZKnvoWcq9fu8f/hUbk2oK14ArNo1TSGFZbJJhGFCqUZZ27dv1t25uymGx/FnY7GxN5b NnPBKl/Juorod+biBbuzWVfJPV/DI/9lge7lz/ei/7vcq+Jeu7d543M1o8ifOTmC5S5iz5RY ijMSDbWYi4oTAYMpEpMxAwAA 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 On 06/27/2013 01:42 PM, Tom Lane wrote: > That will break things: CURRENT_DATE will then be equivalent to just > writing today's date as a literal. Interesting. I tested it by creating a view and a table with a default, and it always seems to get translated to: ('now'::text)::date But I'll take your explanation at face value, since that doesn't imply what the output would be. What's interesting is that EnterpriseDB has their own pg_catalog.current_date function that gets called by the CURRENT_DATE keyword. So unlike in vanilla PG, I could mark just the current_date function as immutable without affecting a lot of other internals. On EDB, this actually works: UPDATE pg_proc SET provolatile = 'i' WHERE proname = 'current_date'; Then the plan gets pared down as desired. But again, if the date were to roll over, I'm not sure what would happen. I wish I could test that without fiddling with machine times. > 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 get it. From the context of two months ago, CURRENT_DATE > '2013-06-20' would return a different answer than it would today, which isn't really good for proofs. The only way for it to work as "expected" would be to add a first pass to resolve any immediate variables, which would effectively throw away plan caches. I'd actually be OK with that. > 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. Fair enough. I'll stop telling devs to use current_date instead of ORM injections, then. Hopefully we can track down and tweak the affected queries on the tables we're partitioning without too much work and QA. Thanks, Tom! -- Shaun Thomas OptionsHouse | 141 W. Jackson Blvd. | Suite 500 | Chicago IL, 60604 312-676-8870 sthomas@optionshouse.com ______________________________________________ See http://www.peak6.com/email_disclaimer/ for terms and conditions related to this email -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance