Home > database > MySQL on the column in the case of bulk insert will be discontinuous (not deleted)
MySQL on the column in the case of bulk insert will be discontinuous (not deleted)
Time:09-22
Recently with MySQL, use the add columns, when performing bulk insert found discontinuous phenomenon, there is no delete, not delete data from empty, Later found the hole size and batch size has something to do, it depends on the generate new auto_increament_value MySQL, The new value will be a 2 n Numbers, the biggest since the number is greater than the bulk insert data referred to in the minimum value of the NTH power of 2, Don't know if this behavior is my specific MySQL version, my version is 5.5.47, Consult a great god, whether have new version or patch has been released, or what set can change this behavior, thanks first,
I tried the following some batch size found the rule, please see the table below: A batch of insert the amount of data, for the new data from the value-added ============================== 1, 2, 2, 4 3, 4 4, 8 5, 8 6, 8 7, 8 August 16th September 16th October 16th November 16th 12 dec 13 dec Dec 14 15 and 16th 16, 32
The following script to interested friend reference, used to produce the discontinuous since value-added script: Drop table if the exists TTT; Drop table if the exists tsource;
The create table if not exists TTT (id int auto_increment primary key, name varchar (50)); The create table if not exists tsource (name varchar (50)); Insert into tsource values (" aaa "), (' BBB '), (" CCC "), (" DDD ");
Insert into TTT (name) Select the name from tsource;
Insert into TTT (name) values (' eee);
Select * from TTT.
CodePudding user response:
5.7.13 test in the jump
CodePudding user response:
May be inserted before the set AUTO_INCREMENT=Max (id) + 1, because the official didn't announce this bug, do not know will not affect storage after change,
CodePudding user response:
The insert for the select statement on the column will be pre-allocated double if enough So you insert four statements are distributed on the column to 8 insert 10 statement must be assigned to 16 article 20 statements are distributed to 32