PHP Maximum number of insertions in a single SQL query

I have a pretty simple question. I insert many records at once into the MySQL table. It works for about 2,000 entries (actually a bit more). But I will say that I want to insert 3,000 entries, which does nothing.

I work through AS3, sending an array containing all the records through AMFPHP, to a simple PHP script to parse and insert the array.

Is this normal, or should I study it?

I am currently splitting my array into parts of 2000 entries and sending multiple AMFPHP requests instead of 1.

+4
source share
4 answers

PHP requests are limited by the "max_allowed_packet" configuration parameter. It defines the absolute length limit in characters, which may be in the query string. Please note that this is not only the total size of the inserted data, but the entire query string. SQL commands, punctuation, spaces, etc.

See how long your 3000-bit version is 2000, and then get the server packet length limit:

SHOW VARIABLES WHERE Variable_name LIKE '%max_allowed_packet%' 

If your version with 3000 instances is longer than this limit, the request will defnitely fail, because it will be partially chopped off

+9
source

I do not think that there really is a limit to the number of insertions in a single query.

Instead, there is a limit on the size of the request you can send to MySQL
Cm.:


So basically it depends on the amount of data that you have in each insert .

+3
source

I would make sure max_allowed_packet bigger than your PHP SQL query.

http://dev.mysql.com/doc/refman/5.5/en/packet-too-large.html

+2
source

I think that PHP does not limit the number of inserted requests to one, instead it limits the amount of memory that the script can take and the maximum execution time .

0
source

All Articles