reactphp-sqlite icon indicating copy to clipboard operation
reactphp-sqlite copied to clipboard

Support streaming result sets

Open clue opened this issue 6 years ago • 0 comments

Currently, the API only supports buffering the whole result set in memory. This makes sense for smaller result sets as working with an in-memory data structure with some dozens or hundreds of records works perfectly fine.

However, when processing larger result sets with hundreds or thousands of records, it would make sense to use a streaming approach so that one is no longer limited by memory in how many records can be processed.

Eventual API will use ReactPHP's existing stream API and could look something like this:

$stream = $db->queryStream('SELECT * FROM users');

$stream->on('data', function ($row) {
    var_dump($row);
});
$stream->on('end', function () {
    echo 'DONE' . PHP_EOL;
});

Refs https://github.com/friends-of-reactphp/mysql/issues/50

clue avatar May 06 '19 09:05 clue