Aerospike SCAN vs Getting all records and post-processing

query
scan

#1

Just a quick question… when performing a scan on records, what is the best performance methodology in terms of open connections etc… is it best to get all the records first, then manipulate them using PHP, or to do the work required as the records are being scanned?

As an example, what would be more performant when looking at say 3k - 5k records with something in the region of 20k connections per second…

this:

$status = $this->getAerospike()->scan('namespace', 'setname', function ($record) {
    // do something to check if the $record = 'this' OR 'that' etc
    if ($record['bins']['this_thing'] === 'that_thing') {
        $result[] = $record['bins'];
    }
});

or this:

$status = $this->getAerospike()->scan('namespace', 'setname', function ($record) {
    // simply add the records to an array and filter them later...
    $result[] = $record['bins'];
});

Also, which is more performant for a similar use case, scan or query?

Many thanks