Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y0x8A-0004rU-8C for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Dec 2014 18:45:58 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y0x89-0004YN-Op for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Dec 2014 18:45:57 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y0x88-0004YF-Hr for pgsql-hackers@postgresql.org; Tue, 16 Dec 2014 18:45:56 +0000 Received: from 01.zmailcloud.com ([192.198.85.104] helo=mx-out-1.zmailcloud.com) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y0x81-0008I4-2X for pgsql-hackers@postgresql.org; Tue, 16 Dec 2014 18:45:54 +0000 Received: from smtp.01.com (smtp.01.com [10.10.0.43]) by mx-out-1.zmailcloud.com (Postfix) with ESMTP id 6B8F1565EB7; Tue, 16 Dec 2014 12:45:48 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by smtp-out-1.01.com (Postfix) with ESMTP id 505E3A05E2; Tue, 16 Dec 2014 12:45:48 -0600 (CST) X-Virus-Scanned: amavisd-new at smtp-out-1.01.com Received: from smtp.01.com ([127.0.0.1]) by localhost (smtp-out-1.01.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ipIizvcqu1Ax; Tue, 16 Dec 2014 12:45:48 -0600 (CST) Received: from smtp.01.com (localhost [127.0.0.1]) by smtp-out-1.01.com (Postfix) with ESMTP id 27AE5A05E3; Tue, 16 Dec 2014 12:45:48 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by smtp-out-1.01.com (Postfix) with ESMTP id 070BCA05E1; Tue, 16 Dec 2014 12:45:48 -0600 (CST) X-Virus-Scanned: amavisd-new at smtp-out-1.01.com Received: from smtp.01.com ([127.0.0.1]) by localhost (smtp-out-1.01.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id aY74Ha-1XDVP; Tue, 16 Dec 2014 12:45:47 -0600 (CST) Received: from [172.47.23.103] (50-0-89-106.dsl.dynamic.fusionbroadband.com [50.0.89.106]) by smtp-out-1.01.com (Postfix) with ESMTPSA id EEF6EA05E2; Tue, 16 Dec 2014 12:45:46 -0600 (CST) Message-ID: <54907DD9.7060306@agliodbs.com> Date: Tue, 16 Dec 2014 10:45:45 -0800 From: Josh Berkus Organization: PostgreSQL Experts Inc. User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Robert Haas , Amit Langote CC: Alvaro Herrera , Claudio Freire , Tom Lane , Pg Hackers Subject: Re: On partitioning References: <007b01d015c6$373c21e0$a5b465a0$@lab.ntt.co.jp> <9766.1418422242@sss.pgh.pa.us> <548B6EE3.3020309@agliodbs.com> <20141213020946.GG1768@alvh.no-ip.org> <001601d0180c$a212f550$e638dff0$@lab.ntt.co.jp> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 12/15/2014 10:55 AM, Robert Haas wrote: >> This means if a user puts arbitrary expressions in a partition definition, say, >> > >> > ... FOR VALUES extract(month from current_date) TO extract(month from current_date + interval '3 months'), >> > >> > we make sure that those expressions are pre-computed to literal values. > I would expect that to fail, just as it would fail if you tried to > build an index using a volatile expression. Yes, I wasn't saying that expressions should be used when *creating* the partitions, which strikes me as a bad idea for several reasons. Expressions should be usable when SELECTing data from the partitions. Right now, they aren't, because the planner picks parttiions well before the rewrite phase which would reduce "extract (month from current_date)" to a constant. Right now, if you partition by an integer ID even, and do: SELECT * FROM partitioned_table WHERE ID = ( 3 + 4 ) ... postgres will scan all partitions because ( 3 + 4 ) is an expression and isn't evaluated until after CE is done. I don't think there's an easy way to do the expression rewrite while we're still in planning, is there? -- Josh Berkus PostgreSQL Experts Inc. http://pgexperts.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers