Creating indexes for partitioned tables
- Last Updated: January 17, 2024
- 3 minute read
- OpenEdge
- Version 12.8
- Documentation
You can use the CREATE INDEX statement
to create partitioned indexes. The following types of indexes are
available for partitioned tables:
- Local index
- Global index
These indexes are selected based on the keys on which the index is defined.
Local Index
A local index must include the partition key column as the leading prefix of its index keys. If there are n partition key columns, then the first n index key components must be the partition key columns. This is also known as a partition aligned index.
Use the following syntax to specify area definitions for each index partition:
Syntax
|
Global Index
A
global index is a single database object, which contains index entries
for all rows, in all partitions, in a partitioned table. For a partitioned
table, all indexes that are not partition aligned are global indexes.
A partition aligned index can be a local index or a global index.
By default, all partition aligned indexes are local indexes. To
create global partition aligned indexes, use the GLOBAL reserved
keyword, as shown below:
Syntax
|
Notes
- The
following semantics apply when using the
CREATE INDEXstatement for partitioned tables:- The partition specified in the
FOR PARTITIONclause must be an existing partition in the table - Partitions can be specified in any order
- The specified area must be present in the table and must be in the type II area
- The table specified in the statements must be a partitioned table
- The partition specified in the
- The following semantics are applicable to local indexes:
- The
existing
AREAclause cannot be used for local indexes. - The
FOR PARTITIONclause is only valid for a partitioned table and a local index. - Only index areas can be specified in the
FOR PARTITIONclause in the above syntax. - The specified area must be a type II area.
- The first real local index created for a partitioned table without a partition schema definition is marked as the default index.
- The initial composite partition of a partitioned table without a partition schema
definition is created with
NO SPACEfor local indexes.
- The
existing
- The following semantics are applicable to global indexes:
- If
an
AREAclause is not specified, the index is created in the default index area of a table partition. A global index can use the area defined in anAREAclause for data in all partitions. - An index created using an unpartitioned column as the prefix of index keys is treated as a global index.
- If an
AREAclause is not specified, the index is created in the default index area of a table partition. - A global index can use an existing
AREAclause. - The
FOR PARTITIONclause cannot be used for creating global indexes. - The
GLOBALclause must be used only for partitioned tables. If it is used to create indexes on any other tables (like shared tables or multi-tenant tables), the SQL engine returns an error. - The
GLOBALclause can also be used to create a global index for a partitioned table without partition schema definition. TheAREAclause must be specified for a global index of a partitioned table without partition schema definition and this area must belong to the type II area.
- If
an
Examples
Creating local indexes
Pub.tpcustomer with
partitions: |
Creating local indexes on a table with partition-specific index areas
Pub.tpcustomer table with
partition specific index areas for partitions partn1 and partn9. |
Creating global indexes
AREA clause: |
Creating global indexes on a table with a partitioning key column
custid is the partitioning
key for the table Pub.tpcustomer: |
Creating a unique global index
orderid is
the partitioning key for the table Pub.tporderid: |