On this page
The slow query log records SQL statements that take longer than a set threshold to finish. On a LogicWeb KVM VPS you can enable it yourself and read the file. On shared hosting you cannot open that log, so you find slow queries with tools like Query Monitor and EXPLAIN instead.
Using the slow query log on a VPS
With root on your KVM VPS you can turn the log on in MySQL or MariaDB. Set slow_query_log = 1 and start with a long_query_time of one or two seconds. After the worst queries are fixed, you can lower that value toward half a second. Each entry shows the query text, how long it ran, and how many rows it examined. If the file grows large, pt-query-digest groups similar statements so you are not scrolling line by line. Turn the log off or raise the threshold when you are finished, because writing every slow statement to disk on a busy server creates its own load.
Finding slow queries on shared hosting
Shared plans use CloudLinux LVE and a shared MariaDB instance, so you do not control the daemon and you do not get a personal slow query log. Install Query Monitor on a staging copy of the site, or paste a suspect query into phpMyAdmin and run EXPLAIN. Staging is the right place to discover problems; production is where you confirm the fix after a cache-warmed page load. If one page fires the same query two hundred times, that is almost always a PHP loop, not a missing index on the last call. Replace the loop with one query that uses a JOIN when you can.
What not to change first
Raising the PHP worker count so more processes wait on the same slow query does not fix the bottleneck. You only get a longer line at the same locked door. LiteSpeed can still show idle capacity while MySQL is the real limit. Read the query plan and the application code before you touch worker settings.
After the query itself is cheap, the next limit on a VPS is often the InnoDB buffer pool, which is a memory setting rather than a logging one. See our guide on the InnoDB buffer pool if you need that next step.
Tagged
Was this article helpful?
Be the first to rate this article.



