Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UsErN-00009A-UQ for pgsql-performance@arkaria.postgresql.org; Thu, 27 Jun 2013 16:15:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1UsErN-0002mY-EA for pgsql-performance@arkaria.postgresql.org; Thu, 27 Jun 2013 16:15:49 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UsErM-0002mS-AL for pgsql-performance@postgresql.org; Thu, 27 Jun 2013 16:15:48 +0000 Received: from smtp2.peak6.com ([38.98.137.9]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UsErJ-0002fF-3L for pgsql-performance@postgresql.org; Thu, 27 Jun 2013 16:15:47 +0000 X-AuditID: 0a02cb20-b7f216d000002f75-1f-51cc652f42cd Received: from sswchi5pcas2.peak6.net (Unknown_Domain [10.100.13.24]) by smtp2.peak6.com (Symantec Messaging Gateway) with SMTP id 92.28.12149.F256CC15; Thu, 27 Jun 2013 11:15:43 -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 11:15:43 -0500 Message-ID: <51CC652F.3010304@optionshouse.com> Date: Thu, 27 Jun 2013 11:15:43 -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: "pgsql-performance@postgresql.org" Subject: Partitions not Working as Expected 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+NgFrrHIsWRmVeSWpSXmKPExsXClcIroaufeibQ4EGjnsX1meeYHRg9Luyb xh7AGNXAaJOYl5dfkliSqpCSWpxsq+RfUJKZn1fskV9anKrgklmcnJOYmZtapKSQmWKrZKyk UJCTmJyam5pXYquUWFCQmpeiZMelgAFsgMoy8xRS85LzUzLz0m2VPIP9dS0sTC11DZXs4pFB QidLxrYTe1kLurkr+j+lNjCe4uhi5OSQEDCROPm+gxnCFpO4cG89WxcjF4eQwAFGidkbPjOC JIQEVjJKnD5eC2LzCuhLfL/RCxTn4GARUJVoehcPEmYT0JWY1L+CDaJcRaLv7A0mEJtfQFhi 34cmsPmiAmES75dNZYUYIyhxcuYTFhBbRMBTYvb+bSwgI4UFtCUmHpUGCTML2EpcmHOdBcKW l9j+dg4zxHhViRXNE9kgTlaQ+H/lHdMERsFZSKbOQtI+C0n7AkbmVYzixWWJyRmZZgXFuSUF RnoFqYnZZnp5qSWbGEGRyHRaYQfj5h6rQ4wCHIxKPLwCcqcDhVgTy4orcw8xSnAwK4nwHvE/ EyjEm5JYWZValB9fVJqTWnyI0QcYGhOZpUST84FJIq8k3tDY1MDU0tTQ1NzU0AiHsJI47z6m ZYFCAunAdJGdmlqQWgQzjomDU6qBMUQnRs34ZNar3V2no2a/44t7Y3tNu8JKT9bvQVvHl2vz 4pLkHKTubwiX72/sS3tySMmTS+Lu+0P//pyY3O9y+bddHUcB56qvcTGFVY/MOJMqv+leLF3q /vP7tLMp+sFaW3IdmHh/PHabpedTmd8ebL21+YqyP9vv7IRLwrI3yk5xdHrLyx5RYinOSDTU Yi4qTgQAPcXJdfECAAA= X-Pg-Spam-Score: 0.8 (/) 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 Hey guys, I suspect I'll get an answer equivalent to "the planner treats that like a variable," but I really hope not because it renders partitions essentially useless to us. This is as recent as 9.1.9 and constraint exclusion is enabled. What I have is this test case: CREATE TABLE part_test ( fake INT, part_col TIMESTAMP WITHOUT TIME ZONE ); CREATE TABLE part_test_1 ( CHECK (part_col >= '2013-05-01' AND part_col < '2013-06-01') ) INHERITS (part_test); CREATE TABLE part_test_2 ( CHECK (part_col >= '2013-04-01' AND part_col < '2013-05-01') ) INHERITS (part_test); And this query performs a sequence scan across all partitions: EXPLAIN ANALYZE SELECT * FROM part_test WHERE part_col > CURRENT_DATE; The CURRENT_DATE value is clearly more recent than any of the partitions, yet it checks them anyway. The only way to get it to properly constrain partitions is to use a static value: EXPLAIN ANALYZE SELECT * FROM part_test WHERE part_col > '2013-06-27'; But developers never do this. Nor should they. I feel like an idiot even asking this, because it seems so wrong, and I can't seem to come up with a workaround other than, "Ok devs, hard code dates into all of your queries from now on." -- 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