PHP mysqlnd memory optimizations: from 49MB to 2MB | Ulf WendelUlf Wendel
Ouahouuu ca j’aime bien 🙂 l’article est (très) technique, mais super intéressant.
Inspired by Antony, Andrey has implemented a memory optimization for the phpmysqlnd library. Depending on your usage pattern and the actual query, memory used for result sets is less and free’d earlier to be reused by the PHP engine. In other cases, the optimization will consume about the same or even more memory. The additional choice is currently available with mysqli only.
Many wheels start spinning when mysqli_query() is called. All the PHP MySQL APIs/extensions (mysqli, PDO_MySQL, mysql) use a client library that handles the networking details and provides a C API to the C extensions. Any recent PHP will default to use the mysqlnd library. The library speaks the MySQL Client Server protocol and handles the communication with the MySQL server. The actions behind a users mysqli_query() are sketched below.
The memory story begins in the C world when mysqlnd fetches query results from MySQL. It ends with passing those results to the PHP.via blog.ulf-wendel.de