A few days ago, I sent a text message to Dongdong, and I had to insert a mobile phone number of more than 10 million at a time. My days
A few days ago, I sent a text message to Dongdong, and I had to insert a mobile phone number of more than 10 million at a time. My days
At first, I did not expect that the data of the 10 million yuan would be inserted into a single number for only 2 w in half an hour. Later, an SQL batch insert statement was improved.
The Code is as follows:
-- Before optimizing the code
Insert into table (mobile) values (138000000 );
Insert into table (mobile) values (138000000 );
Insert into table (mobile) values (138000000 );
......
-- Optimized
Insert into table (mobile) values (138000000), (138000000), (138000000 );......
-- After optimization, million data is inserted, including php for data processing, with an overhead of about 6 s.