Size difference when exporting using different MAX INSERT SIZE value of 0

jgudo's profile image jgudo posted 2 years ago in General Permalink

I was exporting a database with an option MAX INSERT SIZE value to 0 and I noticed that the file size of the export was bigger as opposed to the default 1024kb. Does it mean that having the default value 1024 to the MAX INSERT SIZE value, the exported data are not complete since it has a smaller file size?

As you can see on the attached photo, the file pelco1gis_07-07-23.sql was exported with 0 MAX INSERT SIZE value and the file size was way bigger as opposed to the file pelco1gis_07-10-23.sql with default value 1024.

1 attachment(s):
  • export
ansgar's profile image ansgar posted 2 years ago Permalink

No. When using a max insert size of 0, each row of data gets its own INSERT command, like so:

INSERT INTO mytable (cola, colb, colc, ...)
  VALUES (vala, valb, valc, ...);
INSERT INTO mytable (cola, colb, colc, ...)
  VALUES (vala, valb, valc, ...);
INSERT INTO mytable (cola, colb, colc, ...)
  VALUES (vala, valb, valc, ...);

In contrast to that, a max insert size of 1024 KB (= 1 MB) generates multiple rows in one extended INSERT command:

INSERT INTO mytable (cola, colb, colc, ...)
  VALUES (vala, valb, valc, ...),
  VALUES (vala, valb, valc, ...),
  VALUES (vala, valb, valc, ...);

HeidiSQL generates as many rows per INSERT as long as it's smaller than the max insert size.

The data is complete, in both ways. Only these extended INSERTs with multiple rows are smaller, as you can see above.

Also, I highly recommend to use a bigger max insert size. When importing the file afterwards, such extended INSERTs execute much faster than a tons of single INSERTs.

That max insert size in HeidiSQL is equivalent to mysqldump's net-buffer-length argument.

jgudo's profile image jgudo posted 2 years ago Permalink

Awesome! Thanks very much for the detailed explanation! Cheers!

Please login to leave a reply, or register at first.