Performance and monitoring
Analyse WordPress SQL queries
In specific cases it can be useful to analyse the SQL queries WordPress generates to find bottlenecks, repetitions or calls coming from a particular plugin.
Recommended method: PHP X-Ray
On our services you can use PHP X-Ray. The report links each query to the file, function or plugin that runs it and shows its time within the request, without having to change WordPress.
Limit the analysis to the problematic URL and a few requests. Then sort the report by duration and confirm that the query repeats across several samples before changing indexes or code.
Temporary alternative inside WordPress
If you need extra information from the admin area itself, use a maintained profiling tool, such as Query Monitor, for the shortest time necessary. Restrict access to administrators, reproduce the problem, and deactivate and delete the tool when you finish.
Do not write every query to a file inside the public root. The statements may contain tokens, email addresses, personal data, internal paths or form values, and the file would also grow with every visit. Enabling SAVEQUERIES also increases memory usage because it keeps every query in the request.
The goal is not to collect the biggest possible log, but to identify a slow query, where it comes from and the context in which it happens. Keep only the evidence you need and delete any temporary log that might contain sensitive data.
Turn the sample into an improvement
Note the URL, whether you were logged in, the total time and the queries that add up to the most time. Tell a single slow query apart from hundreds of small repeated queries. Repeat the measurement under a comparable load and check whether the response was covered by the page cache: in that case WordPress may not run and no new trace may appear.
Test any change to an index, plugin or query on a copy and compare both reads and writes. If you share a report with the developer, remove personal values and credentials; do not publish the full SQL dump to show a performance problem.
You may also find useful
- Error log View the recent entries in the web error log in cPanel, link them to an incident and tell their scop...
- Raw access log Download the raw HTTP and HTTPS logs from cPanel, with IP, browser, URL and response code, to analys...
- Enable statistics from the Metrics Editor Enable AWStats from cPanel's Metrics Editor only when you need local statistics, avoiding resource a...
- View access statistics with AWStats View AWStats reports based on the server logs and tell apart requests, visits and automated traffic...
Something wrong or out of date? Tell us and we will review it.