The performance schema and advanced query optimization

The art of query optimization can be pushed a little further still by using MariaDB's (MySQL) performance schema to profile queries. Query profiling allows us to see what is happening under the hood and to further optimize complex queries.

To begin, let's enable the performance schema on our database server. To do so, enter these commands on the Linux for PHP container's CLI:

# sed -i '/myisam_sort_buffer_size =/a performance_schema = ON' /etc/mysql/my.cnf # sed -i '/performance_schema =/a performance-schema-instrument = "stage/%=ON"' /etc/mysql/my.cnf # sed -i '/performance-schema-instrument =/a performance-schema-consumer-events-stages-current = ON' /etc/mysql/my.cnf # sed -i '/performance-schema-consumer-events-stages-current ...

Get Mastering The Faster Web with PHP, MySQL, and JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.