When swoole asynchronous mysql acquires big data, it simply exits and no data is returned.

  • simply use the asynchronous mysql client of swoole to obtain 100000 data. After spending a long period of time in php7 in one environment, you can execute the callback method of query to output data, but in the php5.4 of another environment, you do not directly exit with any error, and there is no callback function that executes to query.

I guess it is the different configuration of PHP. The data of 10, 000 is fine, but I don"t know how to modify the configuration

$db->connect($server, function ($db, $r) {
    $dbPreix = "m_";
    if ($r === false) {
        var_dump($db->connect_errno, $db->connect_error);
        die;
    }
    //
    $sql = "SELECT queue_id,group_id,content,data,keyword FROM ".$dbPreix."_queue ".
            "WHERE 1=1 limit 100000";
    $db->query($sql, function(swoole_mysql $db, $r) {
        print_r($r);
    });
Mar.06,2021

this should be caused by a memory overflow. The configuration of the memory overflow is php.ini , which may be caused by different configurations.

solution: do not query at one time, query in batches in callback (refer to paging principle)


solution: reduce the amount of data queried or increase the running memory of php.

in php.ini, find the item "memory_limit". If not, you can add this parameter to the end of the file yourself.

memory_limit = 128M ; -sharp128M

can also be changed directly in the code

ini_set('memory_limit', '128M');
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e97aab-47433.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e97aab-47433.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?