KEY Partitioning Type

You are viewing an old version of this article. View the current version here.

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 similarly 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 can not 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.