Get the App
SLTechnology News&Howtos  ›  Database  › 

Examples of four methods for mysql to insert data in large quantities

Shulou Source: shulou.com Published: 2022-06-01 03:53:24 10月03日 Update

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.

Tags: Data method code large ordinary field database reference learning ten thousand articles small business content at the same time framework resources logic problems generation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Docker Huawei Shulou Technology Redmi