Hi Tomas, Thanks for your comments and sorry for replying so late.
On 2016/01/22 22:54, Tomas Vondra wrote: > thanks for working on this. Seems the last version of the patch was > submitted more than 2 months ago and I believe large parts of it will get > reworked based on the extensive discussion on this list, so I haven't > looked at the code at all. > > I'd like to comment on the one thing and that's the syntax. It seems to me > we're really trying to reinvent the wheel and come up with our own version > of the syntax. Is there a particular reason why not to look at the syntax > of the other databases and adapt as much of the existing syntax as possible? > > I think that's for a few reasons - firstly it makes the life much easier > for the DBAs and users who are either migrating to PostgreSQL or have to > manage a mix of databases. Secondly, it serves as a valuable source of > engineering info, preventing the "I haven't thought of this use case" > problem. > > An example of this is the proposed syntax for adding a partition > > CREATE TABLE measurement_fail > PARTITION OF measurement > FOR VALUES START ('2006-02-15') END ('2006-03-01'); > > which seems a bit awkward as both the databases I'm familiar with (Oracle > and Sybase) use ALTER TABLE to do this > > ALTER TABLE measurement > ADD PARTITION measurement_fail VALUES LESS THAN ( ... ) Syntax like the one you mention allows to create/modify/move/drop partitions at 2 levels (generally) using PARTITION and SUBPARTITION keywords. That might be limiting to some users. I don't have a clear picture of what a syntax that's general enough would look like, but I proposed something like what follows: CREATE TABLE parent ( a int, b char(10) ) PARTITION BY RANGE ON (a) SUBPARTITION BY LIST ON ((substring(b from 1 for 2))); CREATE PARTITION partname OF parent FOR VALUES LESS THAN (100); CREATE PARTITION subpartname OF partname FOR VALUES IN ('ab'); The latter of the CREATE PARTITION commands lets us create the so-called sub-partition of 'parent'. Remember that in this scheme, all level 1 partitions are not actually physical tables themselves; only level 2 partitions are. If you stick one more SUBPARTITION BY in parent's definition, you can: CREATE PARTITION subsubpartname OF subpartname FOR VALUES ...; This is something that the Oracle-like syntax won't be able to support. Although, if we all agree that we'd never want to support such a case then let's implement something that's familiar viz. the following: CREATE TABLE parent ( a int, b char(10) ) PARTITION BY RANGE ON (a) SUBPARTITION BY LIST ON ((substring(b from 1 for 2))); ALTER TABLE parent ADD PARTITION partname FOR VALUES LESS THAN (100); ALTER TABLE parent MODIFY PARTITION partname ADD SUBPARTITION subpartname FOR VALUES IN ('ab'); ALTER TABLE parent MODIFY PARTITION partname DROP SUBPARTITION subpartname; ALTER TABLE parent DROP PARTITION partname; > And so on for the other commands. > > That being said, I entirely agree with Simon (and others) that getting the > planner part work is the crucial part of the patch. But I also think that > a proper abstraction (thanks to good syntax) may be a valuable hint how to > define the catalogs and such. I tried to do that in the November commitfest but decided to just work on the syntax as it became clear that throwing too many changes at the reviewers/committers like that may not be such a great idea. Syntax itself is a big enough change to discuss and reach consensus on. Let's get the syntax, catalog and some infrastructure for basic features of the new partitioning to work. We can think about planner enhancements for partitioned tables that are waiting for declarative partitioning to get in later. Thanks, Amit -- Sent via pgsql-hackers mailing list (email@example.com) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers