This is to get feedback to meet the following TODO:

  - Simplify ability to create partitioned tables

  This would allow creation of partitioned tables without requiring
  creation of rules for INSERT/UPDATE/DELETE, and constraints for rapid
  partition selection. Options could include range and hash partition

There was some discussion on the pgsql mailing lists, which lead to the
above TODO:

We can have the following syntax to support auto creation of partitions in

CREATE TABLE tabname (
| RANGE(expr)
| LIST(expr)
[PARTITIONS num_partitions] /* will apply to HASH only for now*/
[PARTITION partition_name CHECK(...),
 PARTITION partition_name CHECK(...)

Here "expr" will be one of the column names as specified for the master
table. Once we finalize the syntax, the above statement would end up
carrying out the following activities (disclaimer: we might add or remove
some activities based on the discussion here).

i ) Create master table.
ii) Create children tables based on the number of partitions specified and
make them inherit from the master table.
iii) Auto generate rules (or triggers?) using the checks mentioned for the
partitions, to handle INSERTs/DELETEs/UPDATEs to navigate them to the
appropriate child. Note that checks specified directly on the master table
will get inherited automatically.
iv) Based on the PRIMARY, UNIQUE, REFERENCES information specified, pass it
on to the children tables.
v) If possible add CHECK (false) to the master table to avoid any activity
on it.

Some questions remain as to:

1) Whether we should use triggers/rules for step number (iii) above. Maybe
rules is the way to go.
2) What other attributes (access permissions e.g.) of the master along with
the ones specified in (iv) should be passed on to the children.
3) Some implementation specific issue e.g. whether SPI_execute would be a
good way of creating these rules.

Comments appreciated,
EnterpriseDB               http://www.enterprisedb.com

Reply via email to