Answer the question
In order to leave comments, you need to log in
How to execute mysql query in php without waiting for it to finish?
You need to execute a query that takes a long time, the result of the query is not important. You need to somehow run it in parallel or run it without waiting for the result ...
Answer the question
In order to leave comments, you need to log in
If it is INSERT, then use INSERT DELAYED:
phpclub.ru/mysql/doc/insert-delayed.html
Also mysqlnd - MySQL native driver for PHP supports asynchronous queries.
www.php.net/manual/en/mysqli.poll.php
system('nohup script.php&') - something like this, but this only works on linux and creates an unnecessary background task load on the database.
A perversion of course, but you can put it in a separate script that will twitch cURL with a response timeout of 1 second.
Use the queuing mechanism.
Meaning: when you need to do something “long-running” due to certain circumstances or events, you “queue for execution” of a certain task. And the queue itself will pop tasks one at a time from the stack and execute them. This can be done, for example, once a minute by cron using a special script - a cron manager.
As an example of implementation, you can look at symphony tasks
Maybe it means that after launching a long-running query, you need to execute other queries in parallel without waiting for its results?
Describe the structure of the tables and the type of query, this may be important to get the right answer.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question