Examples of four methods for mysql to insert data in large quantities
preface
This article mainly introduces you about mysql mass insertion of data 4 methods, share it for your reference learning, the following words do not say much, let's take a look at the detailed introduction
Method 1: Circular insertion
This is also the most common way, if the amount of data is not very large, can be used, but each time to consume resources connected to the database.
Think roughly as follows
(I write pseudocode here, and the specific writing can be written in combination with my own business logic or framework syntax)
for($i=1;$i $value){$sql = 'insert............... '; //querysql}while($i exec($sql); if (!$ res) { //TODO insertion failed } @unlink($my_file); }}
This also has a large amount of data per entry, with many varchar4000 and text fields.
Time 2.160s
The above meets the basic needs, 1 million data is not a problem, or the data is too large and involves sub-database sub-table, or queue insertion.
summary
The above is all the content of this article, I hope the content of this article for everyone's study or work has a certain reference learning value, thank you for your support.