# `VERSION::8.5.0` Global Index
+ A global index 
  + Covers the data of the entire table with a single index
  + Allows keys to maintain global uniqueness without including all partition keys
  + Can access index data across multiple partitions in a single operation

```
tidb> CREATE TABLE t1 (
    ->     col1 INT NOT NULL,
    ->     col2 DATE NOT NULL,
    ->     col3 INT NOT NULL,
    ->     col4 INT NOT NULL,
    ->     UNIQUE KEY uidx12(col1, col2) GLOBAL,
    ->     UNIQUE KEY uidx3(col3)
    -> )
    -> PARTITION BY HASH(col3)
    -> PARTITIONS 4;
Query OK, 0 rows affected (0.12 sec)
```

------------------------------------------------------------------------------
Before the introduction of global indexes, TiDB created a local index for each partition, leading to a limitation that primary keys and unique keys had to include the partition key to ensure data uniqueness. Additionally, when querying data across multiple partitions, TiDB needed to scan the data of each partition to return results.

To address these issues, TiDB introduces the global indexes feature in v8.3.0. V8.5.0 is the first LTS version with global index. A global index covers the data of the entire table with a single index, allowing primary keys and unique keys to maintain global uniqueness without including all partition keys. Moreover, global indexes can access index data across multiple partitions in a single operation, significantly improving query performance for non-partitioned keys instead of looking up in one local index for each partition.

To create a global index for a primary key or unique key, you can add the GLOBAL keyword in the index definition.

```
CREATE TABLE t1 (
    col1 INT NOT NULL,
    col2 DATE NOT NULL,
    col3 INT NOT NULL,
    col4 INT NOT NULL,
    UNIQUE KEY uidx12(col1, col2) GLOBAL,
    UNIQUE KEY uidx3(col3)
)
PARTITION BY HASH(col3)
PARTITIONS 4;
```

In the preceding example, the unique index `uidx12` is a global index, while `uidx3` is a regular unique index.