# Hotspot of Clustered Index

![`smart`](HotspotofClusteredIndex_aa_004_20230906.png)

```
CREATE TABLE sbtest1(
 ~!@id int(11) NOT NULL AUTO_INCREMENT,@!~
 k int(11) NOT NULL DEFAULT '0',
 c char(120) NOT NULL DEFAULT '',
 pad CHAR(60) DEFAULT '' NOT NULL,
 ~!@PRIMARY KEY (id) CLUSTERED@!~
)
```

----------------------------------------------------
Hotspot of Clustered Index
In the Slide, in Step 1, we executed the SQL statement `insert into T values ('Tony', 1391113134)`. Since the `ID` column has the AUTO_INCREMENT property, the TiDB database automatically assigns it a value that is one greater than the previously inserted `ID` column value. In the Slide, the `ID` is 4.
In Step 2, we retrieve from PD (Placement Driver) the region where "4, Tony, 1391113134" should be inserted. Clearly, it is the same region where the previous `id` 3 was inserted.
Step 3 involves the actual insertion of the data. In this process, we observe that the `ID` column is an auto-incremented primary key. Since the key-value pairs in the region are sorted, each write operation will target the region that was most recently created. 
Consequently, with each data insertion, the writes will continue to target the preceding region. When concurrent insert operations occur, this region's TiKV node becomes a hotspot.
In conclusion, in a Clustered Index Table, if the primary key has the AUTO_INCREMENT property, there is a possibility of forming hotspots during data insertion.


