It takes a lot of time for mysql to insert multiple data records.
Select * from users;
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0 ");
Insert into users (name, age, course_id) VALUES ("test", 1, "0"), ("test", 1, "0"), ("test ", 1, "0"), ("test", 1, "0 "),
("Test", 1, "0"), ("test", 1, "0"), ("test", 1, "0 "), ("test", 1, "0 "),
("Test", 1, "0"), ("test", 1, "0"), ("test", 1, "0 "), ("test", 1, "0 "),
("Test", 1, "0"), ("test", 1, "0"), ("test", 1, "0 "), ("test", 1, "0 "),
("Test", 1, "0"), ("test", 1, "0"), ("test", 1, "0 "), ("test", 1, "0 "),
("Test", 1, "0"), ("test", 1, "0"), ("test", 1, "0 "), ("test", 1, "0 ")
When inserting the above 24 data records, we found that the execution efficiency of the two items was significantly different (nearly 10 times)
Method 1:
Method 2:
Is the internal implementation of the batch processing in jdbc implemented in the form of method 2? If you are interested, you can view the source code of this part...