📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

SET CLUSTER KEY



Set a cluster key when creating a table.

Cluster key is intended to improve query performance by physically clustering data together. For example, when you set a column as your cluster key for a table, the table data will be physically sorted by the column you set. This will maximize the query performance if your most queries are filtered by the column.

See also:

Syntax

CREATE TABLE <name> ... CLUSTER BY ( <expr1> [ , <expr2> ... ] )

Examples

This command creates a table clustered by columns:

CREATE TABLE t1(a int, b int) CLUSTER BY(b,a); CREATE TABLE t2(a int, b string) CLUSTER BY(SUBSTRING(b, 5, 6));

Was this page helpful?