pgsql: Implement table partitioning. - Mailing list pgsql-committers

From Robert Haas
Subject pgsql: Implement table partitioning.
Date
Msg-id E1cEgoz-0001H4-UP@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Implement table partitioning.

Table partitioning is like table inheritance and reuses much of the
existing infrastructure, but there are some important differences.
The parent is called a partitioned table and is always empty; it may
not have indexes or non-inherited constraints, since those make no
sense for a relation with no data of its own.  The children are called
partitions and contain all of the actual data.  Each partition has an
implicit partitioning constraint.  Multiple inheritance is not
allowed, and partitioning and inheritance can't be mixed.  Partitions
can't have extra columns and may not allow nulls unless the parent
does.  Tuples inserted into the parent are automatically routed to the
correct partition, so tuple-routing ON INSERT triggers are not needed.
Tuple routing isn't yet supported for partitions which are foreign
tables, and it doesn't handle updates that cross partition boundaries.

Currently, tables can be range-partitioned or list-partitioned.  List
partitioning is limited to a single column, but range partitioning can
involve multiple columns.  A partitioning "column" can be an
expression.

Because table partitioning is less general than table inheritance, it
is hoped that it will be easier to reason about properties of
partitions, and therefore that this will serve as a better foundation
for a variety of possible optimizations, including query planner
optimizations.  The tuple routing based which this patch does based on
the implicit partitioning constraints is an example of this, but it
seems likely that many other useful optimizations are also possible.

Amit Langote, reviewed and tested by Robert Haas, Ashutosh Bapat,
Amit Kapila, Rajkumar Raghuwanshi, Corey Huinker, Jaime Casanova,
Rushabh Lathia, Erik Rijkers, among others.  Minor revisions by me.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/f0e44751d7175fa3394da2c8f85e3ceb3cdbfe63

Modified Files
--------------
doc/src/sgml/catalogs.sgml                 |  129 +-
doc/src/sgml/ref/alter_table.sgml          |  117 +-
doc/src/sgml/ref/create_foreign_table.sgml |   26 +
doc/src/sgml/ref/create_table.sgml         |  154 +++
src/backend/access/common/reloptions.c     |    2 +
src/backend/catalog/Makefile               |    4 +-
src/backend/catalog/aclchk.c               |    2 +
src/backend/catalog/dependency.c           |   10 +-
src/backend/catalog/heap.c                 |  270 +++-
src/backend/catalog/index.c                |    4 +-
src/backend/catalog/objectaddress.c        |    5 +-
src/backend/catalog/partition.c            | 1917 ++++++++++++++++++++++++++++
src/backend/catalog/pg_constraint.c        |    2 +-
src/backend/commands/analyze.c             |    6 +-
src/backend/commands/copy.c                |  174 ++-
src/backend/commands/createas.c            |    2 +-
src/backend/commands/indexcmds.c           |   24 +-
src/backend/commands/lockcmds.c            |    2 +-
src/backend/commands/policy.c              |    5 +-
src/backend/commands/seclabel.c            |    3 +-
src/backend/commands/sequence.c            |    5 +-
src/backend/commands/tablecmds.c           | 1567 +++++++++++++++++++++--
src/backend/commands/trigger.c             |   16 +-
src/backend/commands/typecmds.c            |    3 +-
src/backend/commands/vacuum.c              |    3 +-
src/backend/commands/view.c                |    3 +-
src/backend/executor/execMain.c            |  125 +-
src/backend/executor/nodeModifyTable.c     |  154 ++-
src/backend/nodes/copyfuncs.c              |   81 ++
src/backend/nodes/equalfuncs.c             |   70 +
src/backend/nodes/nodeFuncs.c              |    6 +
src/backend/nodes/outfuncs.c               |   55 +
src/backend/nodes/readfuncs.c              |   34 +
src/backend/optimizer/util/plancat.c       |   20 +
src/backend/parser/analyze.c               |    8 +
src/backend/parser/gram.y                  |  347 ++++-
src/backend/parser/parse_agg.c             |   10 +
src/backend/parser/parse_expr.c            |    5 +
src/backend/parser/parse_func.c            |    3 +
src/backend/parser/parse_utilcmd.c         |  326 ++++-
src/backend/rewrite/rewriteDefine.c        |    3 +-
src/backend/rewrite/rewriteHandler.c       |    3 +-
src/backend/rewrite/rowsecurity.c          |    3 +-
src/backend/tcop/utility.c                 |    6 +-
src/backend/utils/adt/ruleutils.c          |  241 ++++
src/backend/utils/cache/relcache.c         |  364 +++++-
src/backend/utils/cache/syscache.c         |   12 +
src/bin/pg_dump/common.c                   |   90 ++
src/bin/pg_dump/pg_dump.c                  |  186 ++-
src/bin/pg_dump/pg_dump.h                  |   14 +
src/bin/psql/describe.c                    |  146 ++-
src/bin/psql/tab-complete.c                |    6 +-
src/include/catalog/catversion.h           |    2 +-
src/include/catalog/dependency.h           |    3 +-
src/include/catalog/heap.h                 |   11 +
src/include/catalog/indexing.h             |    3 +
src/include/catalog/partition.h            |   83 ++
src/include/catalog/pg_class.h             |   23 +-
src/include/catalog/pg_partitioned_table.h |   76 ++
src/include/catalog/pg_proc.h              |    2 +
src/include/commands/defrem.h              |    2 +
src/include/commands/tablecmds.h           |    2 +-
src/include/executor/executor.h            |    6 +
src/include/nodes/execnodes.h              |   14 +
src/include/nodes/nodes.h                  |    5 +
src/include/nodes/parsenodes.h             |   79 +-
src/include/parser/kwlist.h                |    2 +
src/include/parser/parse_node.h            |    3 +-
src/include/parser/parse_utilcmd.h         |    2 +
src/include/pg_config_manual.h             |    5 +
src/include/utils/builtins.h               |    1 +
src/include/utils/rel.h                    |   89 ++
src/include/utils/syscache.h               |    1 +
src/test/regress/expected/alter_table.out  |  343 +++++
src/test/regress/expected/create_table.out |  413 ++++++
src/test/regress/expected/inherit.out      |  272 ++++
src/test/regress/expected/insert.out       |  140 ++
src/test/regress/expected/sanity_check.out |    1 +
src/test/regress/expected/update.out       |   27 +
src/test/regress/sql/alter_table.sql       |  294 +++++
src/test/regress/sql/create_table.sql      |  315 +++++
src/test/regress/sql/inherit.sql           |   52 +
src/test/regress/sql/insert.sql            |   86 ++
src/test/regress/sql/update.sql            |   21 +
src/tools/pgindent/typedefs.list           |    6 +
85 files changed, 8886 insertions(+), 271 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Restore psql's SIGPIPE setting if popen() fails.
Next
From: Robert Haas
Date:
Subject: pgsql: Replace references to COLLATE "en_US" with COLLATE "C".