Jump to content

MySQL Query Timeout


johnslater

Recommended Posts

I'm running a PHP script that runs through an array containg quite a few records. This array has each row outputted and then this row is placed into the database. The problem is MySQL decides to stop half way through the query and say "MySQL has gone away" or "Lost connection to MySQL server during query" meaning nothing every gets entered into the database anyway.

 

Don't suppose there is a way to split the query so it only inserts 100 at a time rather than trying to get all of them in?

Link to comment
Share on other sites

instead of

 

mysql_query("INSERT INTO tablename (a,b,c) VALUES (x1,y1,z1)");
mysql_query("INSERT INTO tablename (a,b,c) VALUES (x2,y2,z2)");
mysql_query("INSERT INTO tablename (a,b,c) VALUES (x3,y3,z3)");

 

try the faster version

mysql_query("INSERT INTO tablename (a,b,c) VALUES
    (x1,y1,z1),
    (x2,y2,z2),
    (x3,y3,z3) ");

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.