M
M
misha912012-03-06 14:00:11
PHP
misha91, 2012-03-06 14:00:11

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

9 answer(s)
S
shagguboy, 2012-03-06
@shagguboy

php.net/manual/ru/mysqli.reap-async-query.php

G
gollum, 2012-03-06
@gollum

If it is INSERT, then use INSERT DELAYED:
phpclub.ru/mysql/doc/insert-delayed.html

G
gollum, 2012-03-06
@gollum

Also mysqlnd - MySQL native driver for PHP supports asynchronous queries.
www.php.net/manual/en/mysqli.poll.php

E
egorinsk, 2012-03-06
@egorinsk

system('nohup script.php&') - something like this, but this only works on linux and creates an unnecessary background task load on the database.

M
MrCrock, 2012-03-06
@MrCrock

A perversion of course, but you can put it in a separate script that will twitch cURL with a response timeout of 1 second.

F
Fastto, 2012-03-06
@Fastto

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

S
Silver_Clash, 2012-03-06
@Silver_Clash

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.

A
aeryaguzov, 2012-03-06
@aeryaguzov

dev.mysql.com/downloads/connector/php-mysqlnd/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question