KEY Partitioning Type

Syntax

PARTITION BY KEY (column_value)
[PARTITIONS (number_of_partitions)]

Description

Partitioning by key is a type of partitioning that is similar to and can be used in a similar way as partitioning by hash.

Just like HASH partitioning, in KEY partitioning the server takes care of the partition and ensures an even distribution among the partitions. However, the largest difference is that KEY partitioning requires a column_value, and cannot accept a partitioning_expression which is based on a column_value, in contrast to HASH partitioning, which can.

It requires a column_value, and the hashing function is given by the server.

Example

CREATE OR REPLACE TABLE t1 (v1 INT)
  PARTITION BY KEY (v1)
  PARTITIONS 2;

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.