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 ...