Skip to content

Commit

Permalink
Add bit reverse example to dev-guide-unique-serial-number-generation (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Tetsuya3850 authored Dec 19, 2023
1 parent 156f411 commit 7b6b947
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion develop/dev-guide-unique-serial-number-generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ The number allocation solution can be understood as bulk acquisition of auto-inc

Every time, the application gets a segment of sequence numbers at the configured step. It updates the database at the same time to persist the maximum value of the current sequence that has been allocated. The processing and allocation of sequence numbers are completed in the application's memory. After a segment of sequence numbers is used up, the application gets a new segment of sequence numbers, which effectively alleviates the pressure on the database write. In practice, you can also adjust the step to control the frequency of database updates.

Finally, note that the IDs generated by the above two solutions are not random enough to be directly used as **primary keys** for TiDB tables. In practice, you can perform bit-reverse on the generated IDs to get more random new IDs.
Finally, note that the IDs generated by the above two solutions are not random enough to be directly used as **primary keys** for TiDB tables. In practice, you can perform bit-reverse on the generated IDs to get more random new IDs. For example, after performing bit-reverse, the ID `00000010100101000001111010011100` becomes `00111001011110000010100101000000`, and `11111111111111111111111111111101` becomes `10111111111111111111111111111111`.

0 comments on commit 7b6b947

Please sign in to comment.