Reputation:
I have a couple tables in which I created an object ID as either an Int or Bigint, and in both cases, they seem to autoincrement by 10 (ie, the first insert is object ID 1, the second is object ID 11, the third is object ID 21, etc). Two questions:
Why does it do that?
Is that a problem?
Upvotes: 48
Views: 45410
Reputation: 939
Please do not change the auto_increment_increment
. ClearDB is doing this on purpose. It's explained in the documentation:
ClearDB uses circular replication to provide master-master MySQL support. As such, certain things such as auto_increment keys (or sequences) must be configured in order for one master not to use the same key as the other, in all cases. We do this by configuring MySQL to skip certain keys, and by enforcing MySQL to use a specific offset for each key used. The reason why we use a value of 10 instead of 2 is for future development.
Upvotes: 57
Reputation: 11
autoincriment value can jump if using insert with IGNORE attribute in case when record was not created
insert IGNORE into my_table set column=1
Upvotes: 1
Reputation: 3896
Thanks @Jim Fiorato for providing the link.
To check how much the auto increment value increments by, use the following query:
SHOW VARIABLES LIKE 'auto_inc%';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| auto_increment_increment | 10 |
| auto_increment_offset | 4 |
+--------------------------+-------+
Upvotes: 22
Reputation: 15011
Check to see the seed value of the autoincrement isn't set to 10.
You can check by:
SELECT Auto_increment FROM information_schema.tables WHERE table_name='the_table_you_want';
As noted elsewhere you can change by using the system variable @@set_auto_increment_increment
SET @@auto_increment_increment=1;
If you want to start the values at a number other than one you can go:
ALTER TABLE tbl AUTO_INCREMENT = 100;
Upvotes: 49
Reputation: 4872
The auto increment increment value is set in the MySQL system variables.
Upvotes: 8