0

I would like to know which solution is faster than the other. So, imagine we'd like to INSERT 10000 rows into a table. We have the following 2 solutions:

Solution 1: Run the INSERT query 10000 times:

INSERT INTO myTable (a,b,c) VALUES ("a","b","c"); x 10000

Solution 2: Run one INSERT query with 10000 rows at once:

INSERT INTO myTable (a,b,c) VALUES 
("a","b","c"),
("a","b","c"),
("a","b","c"),
 ...,
("a","b","c");
disasterkid
  • 6,948
  • 25
  • 94
  • 179

2 Answers2

1

Solution 2 : it need just one connection to the database, the solution 1 need 1000 connections and it's so mush.

Zakaria.dem
  • 293
  • 5
  • 10
1

Solution 1 is around 10 times slower than solution 2.

From the guy with the mysql database server with 100gb data and 5000 request per second.

Gleiemeister 2000
  • 731
  • 4
  • 9
  • 23