Systems | Development | Analytics | API | Testing

Updating access timestamps without wrecking the database

When you want to know the last time some user was seen or some resource was accessed/viewed, then usually you reach to a timestamp column and update this to the current time whenever it’s seen or accessed. You may have written this kind of SQL statement (or the equivalent) in your ORM yourself a few times: It looks innocent, but even on reasonably small tables, this can cause slow UPDATE statements regularly.

New in PHP 8.6: Narrowing the array_map vs foreach performance gap

With PHP 8.6, array_map gets about 10% faster in a synthetic benchmark — with zero changes to your code. My colleague Tim contributed the engine-level optimization that makes this possible. With PHP 8.6, the engine will automatically improve the following code: To turn array_map into a foreach loop as an engine optimization, PHP sees and executes this code as if it was written like this: This improves performance in a synthetic benchmark by about 10%.