MarvinLeRouge
MarvinLeRouge

Reputation: 534

MySql query : don't wait for result

I'd like to know if it's possible to execute a mysql query, and not wait for result. Explanation : i have an insert query in a php page, which take some time, but it's not necessary for the page display to wait that it's complete. It's statistics, so even if it failed, it's not important. I tried to use MYSQLI_ASYNC, but then, the very next request gets this error message :

Array
(
    [code] => 2014
    [message] => Commands out of sync; you can't run this command now
)

Any idea ? Thanks.

Upvotes: 2

Views: 2047

Answers (2)

MarvinLeRouge
MarvinLeRouge

Reputation: 534

It seems like i found what i needed :

  • this is a log table, with no relation to anything else => switch it to myisam => inserts much faster
  • plus insert delayed for 0 wait time

Initial insert time : 90-120ms New insert time : 1-2ms

Yessss !!!

Upvotes: 2

Evert
Evert

Reputation: 99525

You can let a MySQL query run asynchronously, but you can't send a second mysql query over the wire before handling the first.

https://secure.php.net/manual/en/mysqli.reap-async-query.php

Upvotes: 1

Related Questions