pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: Robert Haas <robertmhaas@gmail.com>
To: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Claudio Freire <klaussfreire@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>
Subject: Re: On partitioning
Date: Tue, 16 Dec 2014 10:45:45 -0800
Message-ID: <54907DD9.7060306@agliodbs.com> (raw)
In-Reply-To: <WM!8cffd9c1cee9a4329fc6359e77402db760b5f8d1643541d65e3238e233ee747cb8155136b36d574ace2fb276dac2a8b2!@asav-3.01.com>
References: <CAA4eK1LcDLmOfw3Y4L9FeAn+pMcLg6OLSTK45G9SBQUvO4tZYQ@mail.gmail.com>
	<CA+TgmoYqwOmL=ykspWmwfFivwA2T3gzyEo_94YZd3L3WpLau4g@mail.gmail.com>
	<007b01d015c6$373c21e0$a5b465a0$@lab.ntt.co.jp>
	<CA+TgmoY=aa2eGzTHn+cepnoz4Exj6bhrkNkghFxSxO84V_WroA@mail.gmail.com>
	<CA+TgmobH--E+GkGHsprjN-e_4-YR4208pmE9zp90sEjBjDBDMg@mail.gmail.com>
	<CAGTBQpaqEbSO+=s1xod1G6xfawc1RRnYEL3jGp870h7APnCgGg@mail.gmail.com>
	<9766.1418422242@sss.pgh.pa.us>
	<WM!5674e59aab89034f672b7668897d87b46824a54cca29a62ba08c1af0387796e192e949d0345717737e6887fc6cabf78c!@asav-3.01.com>
	<548B6EE3.3020309@agliodbs.com>
	<CAGTBQpby6DG1E1T+9wfGzMat46OWCxmQ5h-AEr6YzA=iYd5dbQ@mail.gmail.com>
	<20141213020946.GG1768@alvh.no-ip.org>
	<001601d0180c$a212f550$e638dff0$@lab.ntt.co.jp>
	<CA+TgmoaA18DL8SG51tDQ=wjQBAqb658cR1TSV3diLmk_x9iRzQ@mail.gmail.com>
	<WM!8cffd9c1cee9a4329fc6359e77402db760b5f8d1643541d65e3238e233ee747cb8155136b36d574ace2fb276dac2a8b2!@asav-3.01.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

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



view thread (169+ messages)  latest in thread

Message-ID: <54907DD9.7060306@agliodbs.com>
Permalink:  ../54907DD9.7060306@agliodbs.com/
Also on:    postgresql.org/message-id/54907DD9.7060306@agliodbs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: josh@agliodbs.com, robertmhaas@gmail.com, Langote_Amit_f8@lab.ntt.co.jp, alvherre@2ndquadrant.com, klaussfreire@gmail.com, tgl@sss.pgh.pa.us
  Subject: Re: On partitioning
  In-Reply-To: <54907DD9.7060306@agliodbs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox