Re: More info on timeout problem, with code
| From: | Chris | Date: | Tue, 06 Nov 2007 23:54:26 +0000 |
| Subject: | Re: More info on timeout problem, with code | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-264154@lists.php.net to get a copy of this message | ||
Jon Westcot wrote:
Hi David, et al.:What indexes are on this table? When you do an insert, each one has to update the index as well as the data, so maybe that's where all the time is being spent in the database (doubt it's the problem but try dropping all of the indexes on the table). Are you commenting out this whole section?Thanks for the comment. I removed the trailing semi-colon in the twoareas where it was being sent to mysql_query() and tried the code again. I'm still getting the same basic problem -- it silently aborts somewhere around 22,000 to 26,000 records being processed out of just under 30,000. When I don't build the $insert_query string, I am able to read through the CSV file completely.
$insert_query = "INSERT INTO evall VALUES(";
for ($c=0; $c < $num; $c++) {
if($c > 0) {
$insert_query .= ",";
}
$insert_query .= '"' . $data[$c] . '"';
}
$insert_query .= ");";
Try
$insert_query = "INSERT INTO evall values ('" . implode('\'', $data) . "')";
so you're not doing a for loop when you don't need to.
Also as someone else suggested if this is a csv file you can use LOAD DATA INFILE to directly import it instead of having to create a bunch of insert queries.
See http://dev.mysql.com/doc/refman/5.1/en/load-data.html
Only do this if you are 100% sure of the data (ie it it sanitized in some other step).
Doubt it. -- Postgresql & php tutorials http://www.designmagick.com/As odd as this sounds, should I put in some type of delay? Could thesystem be thinking it's getting flooded by all of the inserts?