1

Im using mysqli multi query to do some inserts and updates in one big lump instead of doing them in lots of seperate queries, basically I don't care about the results even if it is an error and ive read on the PHP.net doc page for the multi_query function I can use this:

while ($mysqli->next_result()) {;}

to go through the results so I can execute more queries. But the problem here seems to be that each loop of that is taking forever to run, if i replace the ; with echo "Next"; its like a half a second between each next being echoed.

Any way i can speed this up, or empty the results or something?

Jack
  • 3,769
  • 6
  • 24
  • 32
  • What do your queries look like? Try optimizing your database. – BoltClock May 08 '11 at 23:36
  • They're not really big queries, just inserting/updating a few ints in the database. But there is sometimes alot of queries in the string im passing to multi_query. The table has lots of rows if that could make a difference? (~220,000) – Jack May 08 '11 at 23:42
  • I think it could, somehow, which is why I also suggested running optimize on your database. – BoltClock May 08 '11 at 23:43
  • Just tried that and it didn't make any difference unfortunatley – Jack May 08 '11 at 23:46
  • did you use the exact setup displayed on PHP.net? `http://php.net/manual/en/mysqli.multi-query.php` - if not, try so, if you did, I guess you need to optimize the data(base) you're running the query on. – Joshua - Pendo May 09 '11 at 05:01
  • OP says, "if i replace the `;` with `echo "Next";` its like a half a second": the problem is not a db optimization problem. Come on, be a little creative. – cbrandolino Sep 29 '11 at 21:57

1 Answers1

0

You could try using

UPDATE LOW_PRIORITY ...

And

INSERT DELAYED ...

If you are using the MyISAM storage engine

Petah
  • 45,477
  • 28
  • 157
  • 213