The best way to invoke and "forget" an async mysqlnd INSERT query

Is this a duplicate?

I checked, and I don’t think so. There are many questions about asynchronous mysql, but I am interested in a specific problem:

Customization

I work with php and mysql in this situation.

Let's say I have my mysqli connection as follows:

$link = new mysqli('localhost', 'root', 'password', 'A_Database');

I installed mysqlnd to execute asynchronous mysql queries using the parameter "MYSQL_ASYNC":

$link->query("INSERT INTO `A_Table` VALUES('stuff!')", MYSQLI_ASYNC);

purpose

, , , , , , . mysql, , .

script . , - :

$links = $errors = $reject = array($link);
if ($link->poll($links, $errors, $reject, 1)) {
    foreach ($links as $resultLink) {
        if ($result = $resultLink->reap_async_query()) {
            if (is_object($result)) {
                $result->free();
            }
        }
    }
}

, .
:

1) , , - , , .

2) ; , .

; (), mysql . " " .

, ?

+4
2

- , , INSERT DELAYED ASYNC:

$link->query("INSERT DELAYED INTO `A_Table` VALUES('stuff!')" );

, . .

+7

, , , , , , "1", "secs" $link->poll($links, $errors, $reject, 1). , 1 . "0", , , .

-, , , , , , . , ASYNC. , , ASYNC, , , , , , - .

, , - , ASYNC .

SQL ( cron), script, Supervisor/Gearman, ( ), . , script CLI, multi-threaded .

(, cron) , (, ), , , ( triggers ), .

+2

Source: https://habr.com/ru/post/1534875/


All Articles