# Key and Value Mapping with Partition for Local Secondary Index

+ Unique Local Secondary Index, **`IndexedColumns`** must contain partition keys
```
Key: PartitionID_IndexID_~!@IndexedColumnsValue@!~
Value: ~!@_tidb_rowid@!~
```

+ Non-Unique Local Secondary Index
```
Key: PartitionID_IndexID_~!@IndexedColumnsValue_tidb_rowid@!~
Value: ~!@NULL@!~
```

------------------------------------------------------------------------------
For a unique secondary index, the index must include every column in the partition key expression. This rule also applies to the primary key since it is unique. In real-world scenarios, there are rare instances where unique local secondary indexes need to be used with partitioned tables.

```
Key: PartitionID_IndexID_IndexedColumnsValue
Value: _tidb_rowid
```

The indexes in TiDB (whether unique or non-unique) are local indexes. As of version 7.5, the TiDB database does not yet support global indexes on partitioned tables. For more information on global and local indexes, please refer to the following information:

- Global Index: A global index is a one-to-many relationship, allowing one index partition to map to many table partitions. This means global index can be partitioned by the range or hash method, and it can be defined on any type of partitioned, or non-partitioned, table.

- Local Index: A local index is a one-to-one mapping between an index partition and a table partition, which means index is also partition by the same conditions of table.

- Proposal: `https://github.com/pingcap/tidb/blob/master/docs/design/2020-08-04-global-index.md`

- Issue: `https://github.com/pingcap/tidb/issues/18032`