Re: [HACKERS] Multi column range partition table - Mailing list pgsql-hackers
From | Dean Rasheed |
---|---|
Subject | Re: [HACKERS] Multi column range partition table |
Date | |
Msg-id | CAEZATCXemu7_KDptQGx4py5t55F4tzunYVFU1Lt5=HJ9-oDJLw@mail.gmail.com Whole thread Raw |
In response to | Re: [HACKERS] Multi column range partition table (Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>) |
Responses |
Re: [HACKERS] Multi column range partition table
|
List | pgsql-hackers |
On 5 July 2017 at 10:43, Amit Langote <Langote_Amit_f8@lab.ntt.co.jp> wrote: > In retrospect, that sounds like something that was implemented in the > earlier versions of the patch, whereby there was no ability to specify > UNBOUNDED on a per-column basis. So the syntax was: > > FROM { (x [, ...]) | UNBOUNDED } TO { (y [, ...]) | UNBOUNDED } > > But, it was pointed out to me [1] that that doesn't address the use case, > for example, where part1 goes up to (10, 10) and part2 goes from (10, 10) > up to (10, unbounded). > [Reading that other thread] It's a reasonable point that our syntax is quite different from Oracle's, and doing this takes it even further away, and removes support for things that they do support. For the record, Oracle allows things like the following: DROP TABLE t1; CREATE TABLE t1 (a NUMBER, b NUMBER, c NUMBER) PARTITION BY RANGE (a,b,c) (PARTITION t1p1 VALUES LESS THAN (1,2,3), PARTITION t1p2 VALUES LESS THAN (2,3,4), PARTITIONt1p3 VALUES LESS THAN (3,MAXVALUE,5), PARTITION t1p4 VALUES LESS THAN (4,MAXVALUE,6) ); INSERT INTO t1 VALUES(1,2,3); INSERT INTO t1 VALUES(2,3,4); INSERT INTO t1 VALUES(3,4,5); INSERT INTO t1 VALUES(3.01,4,5); INSERT INTO t1 VALUES(4,5,10); COLUMN subobject_name FORMAT a20; SELECT a, b, c, subobject_name FROM t1, user_objects oWHERE o.data_object_id = dbms_rowid.rowid_object(t1.ROWID)ORDER BYa,b,c; A B C SUBOBJECT_NAME ---------- ---------- ---------- -------------------- 1 2 3 T1P2 2 3 4T1P3 3 4 5 T1P3 3.01 4 5 T1P4 4 5 10 T1P4 So they use MAXVALUE instead of UNBOUNDED for an upper bound, which is more explicit. They don't have an equivalent MINVALUE, but it's arguably not necessary, since the first partition's lower bound is implicitly unbounded. With this syntax they don't need to worry about gaps or overlaps between partitions, which is nice, but arguably less flexible. They're also more lax about allowing finite values after MAXVALUE, and they document the fact that any value after a MAXVALUE is ignored. I don't think their scheme provides any way to define a partition of the above table that would hold all rows for which a < some value. So if we were to go for maximum flexibility and compatibility with Oracle, then perhaps what we would do is more like the original idea of UNBOUNDED ABOVE/BELOW, except call them MINVALUE and MAXVALUE, which conveniently are already unreserved keywords, as well as being much shorter. Plus, we would also relax the constraint about having finite values after MINVALUE/MAXVALUE. I think I'll go play around with that idea to see what it looks like in practice. Your previous patch already does much of that, and is far less invasive. Regards, Dean
pgsql-hackers by date: