Skip to content

Conversation

shenli
Copy link
Member

@shenli shenli commented Dec 17, 2017

To avoid single hot-region writing. If the random_scatter option is set. We will use bit-operations to randomize the explicit/implicit auto generated id. For example:

mysql> CREATE TABLE `t` (
    ->   `c` bigint DEFAULT NULL AUTO_INCREMENT KEY
    -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin RANDOM_SCATTER=4;
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t values (), (), ();
Query OK, 3 rows affected (0.10 sec)

mysql> select * from t;
+---------------------+
| c                   |
+---------------------+
| 1152921504606846976 |
| 2305843009213693952 |
| 3458764513820540928 |
+---------------------+
3 rows in set (0.00 sec)

mysql> insert into t values (), (), ();
Query OK, 3 rows affected (0.01 sec)

mysql> select * from t;
+---------------------+
| c                   |
+---------------------+
| 1152921504606846976 |
| 2305843009213693952 |
| 3458764513820540928 |
| 4611686018427387904 |
| 5764607523034234880 |
| 6917529027641081856 |
+---------------------+
6 rows in set (0.00 sec)

mysql> insert into t values (), (), ();
Query OK, 3 rows affected (0.00 sec)

mysql> select * from t;
+----------------------+
| c                    |
+----------------------+
| -9223372036854775808 |
| -8070450532247928832 |
|  1152921504606846976 |
|  2305843009213693952 |
|  3458764513820540928 |
|  4611686018427387904 |
|  5764607523034234880 |
|  6917529027641081856 |
|  8070450532247928832 |
+----------------------+
9 rows in set (0.00 sec)

To avoid single hot-region insert for a table.
@shenli shenli added the DNM label Dec 17, 2017
@winoros
Copy link
Member

winoros commented Dec 18, 2017

This will make AUTO_INCREMENT meaningless.

@winkyao
Copy link
Contributor

winkyao commented Dec 21, 2017

how about add a RANDOM KEY syntax , and replace AUTO_INCREMENT KEY with it?

@shenli
Copy link
Member Author

shenli commented Dec 27, 2017

Duplicate with #5513

@shenli shenli closed this Dec 27, 2017
@shenli shenli deleted the random-id branch July 27, 2018 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants