## Module 4: Use AUTO_RANDOM Instead of AUTO_INCREMENT To Avoid Hotspots

+ In a distributed database like TiDB, data is divided into regions and distributed across multiple storage nodes (TiKV nodes).

+ `AUTO_INCREMENT` Problem:
  + When using `AUTO_INCREMENT`, IDs are sequential (1, 2, 3, 4, ...)
  + New inserts all go to the same region where the latest IDs are stored
  + This creates a "hotspot" where one storage node handles most write traffic
  + The rest of the storage nodes are underutilized
  + This bottleneck can severely limit write throughput

+ `AUTO_RANDOM` Solution:
  + `AUTO_RANDOM` generates non-sequential, distributed IDs
  + These shard bits help distribute writes across different regions
  + The INSERT workload is balanced across all storage nodes
  + This improves write throughput and scalability for high-concurrency scenarios

  ```bash
  poetry run python mysql_connector_python_demo/auto_random.py
  ```

  ```output
  ...
  AUTO_RANDOM IDs (distributed to avoid hotspots):
  3
  288230376151711748
  1441151880758558729
  1729382256910270465
  3458764513820540934
  3458764513820540935
  4899916394579099650
  5764607523034234888
  6917529027641081866
  7782220156096217093

  AUTO_INCREMENT IDs (sequential, can cause hotspots):
  1
  2
  3
  4
  5
  6
  7
  8
  9
  10
  ...
  ```
