Introduction to Table Partitions and Storage Groups

Table Partitions

A table partition is an attribute that can be associated with an SQL table. The partition contains a subset of the row versions that are stored on and serviced by a storage group. The subset stored in the partition is governed by a partitioning policy. A partitioned table must contain at least one table partition and may contain multiple table partitions. Table partitions are associated with SQL tables by specifying partition criteria. Each partition within a table has a uniquely identified name that maps to one storage group.

NuoDB uses two levels of mapping between a version of a row in a horizontally partitioned table and physical storage. The first mapping level uses table partitioning which provides the ability to map a table partition, which contains a version of a row, to exactly one symbolic storage group name. The second mapping level assigns a storage group, a logical storage unit, to one or more storage managers in the database.

Storage Groups

A storage group represents a logical storage unit that can be serviced by multiple Storage Managers (SMs) in a database.

partitions and SGs

A storage group is referenced by a symbolic identifier that uniquely identifies a storage group within the database. These symbolic identifiers allow table partitioning policies to reference a symbolic name as opposed to a static storage location.

The storage group to SM assignments provide the flexibility to dynamically change the mapping to accommodate database operational requirements without a service interruption. The relationship between storage groups and SMs is a many-to-many mapping, that is, a storage group can be serviced by one or more SMs. In addition, an SM may service one or more storage groups.

For information on adding storage groups, see Managing Storage Groups.

Unpartitioned Tables

An unpartitioned table is a table for which no partitioning rules have been defined.

There is one predefined storage group named UNPARTITIONED. SMs that service the UNPARTITIONED storage group store data for all unpartitioned tables in the database. All SMs service the UNPARTITIONED storage group. By default, a row in an unpartitioned NuoDB SQL table is stored in the UNPARTITIONED storage group which is serviced by all SMs in a database.

Table partitions allow you to store the data being inserted in one or more storage groups in the database, based on the value of a column in that row. For example, a simple table partitioning use case would be a table containing user data that is partitioned based on the user’s zip code column. The inserted data is stored into table partitions that map to storage group names that represent the geographical storage location near the zip code of the row being inserted. Then the storage groups are fulfilled by assigning SMs that are located in those geographical locations, for example, the USWEST storage group is serviced by an SM located in San Diego, CA and the USEAST storage group is serviced by an SM located in Cambridge, MA.

Partitioning an Unpartitioned Table

An unpartitioned table can be partitioned under the following circumstances:
1. Only range-style partitioning is supported.
2. All unique indexes must contain the partitioning column or an autogenerated column.
The resulting partitioned table will have a first partition that contains all the data from the original table, including existing indexes.

A table can be partitioned using the following syntax:

ALTER TABLE [table] MODIFY PARTITION BY RANGE (column_name)
    [STORE IN default_storage_group]
    PARTITION partition_name VALUES LESS THAN (literal | MAXVALUE)
    [STORE IN storage_group]

See ALTER TABLE for more information and examples.