In theory, there is no limit to how much data you can insert via an INSERT
statement. But, in practice you may be limited by the max_allowed_packet
, which defaults to 1MB. One option would be to temporarily increase max_allowed_packet
to a value which can support inserting 1 million records. An alternative to this might be to use LOAD DATA
with a CSV file containing your data.
One motivation for not doing a single insert is that, given the large size of the insert, should it fail somewhere in the middle, e.g. due to network issues, you could either lose the entire transaction, or end up with a partial insert. So, you might want to break your insert into smaller batches, if for no other reason than it makes it safer.