preloader

Query Monitor: How to Actually Read and Fix What It Shows You

Query Monitor shows you what WordPress is doing on each page load. Most tutorials cover how to install it. This one covers how to read the output and what to do about what you find.

The Admin Bar Summary

Query Monitor adds a summary to the admin bar when you are logged in as an administrator. The numbers shown are: total database queries, total query time, total page generation time, and memory used. These give you a baseline to compare pages against each other.

Rules of thumb for healthy WordPress sites: under 50 queries per page, under 100ms total query time, under 500ms page generation time. Numbers significantly above these suggest something worth investigating.

Reading the Queries Panel

Click the Query Monitor admin bar item and go to the Queries tab. By default queries are sorted by execution order. Change the sort to “Time” to see the slowest queries first – these are your priorities.

For each query, Query Monitor shows:

  • The full SQL
  • Execution time in milliseconds
  • The calling function – which plugin or theme triggered this query
  • The result row count

A query taking over 50ms is worth examining. Click the caller to see the full stack trace.

Diagnosing a Slow Query

Copy a slow query from Query Monitor and run EXPLAIN on it directly in your database (phpMyAdmin, TablePlus, or WP-CLI):

EXPLAIN SELECT * FROM wp_postmeta WHERE meta_key = 'price' AND meta_value > 100;

Look at the “Extra” column in the EXPLAIN output. “Using where” without “Using index” means the query is scanning rows without an index – the most common cause of slow meta queries. “Using filesort” means MySQL is sorting results in memory rather than using an index – also slow on large tables.

The fix for missing index: add one. For wp_postmeta queries filtering on meta_value:

ALTER TABLE wp_postmeta ADD INDEX meta_value_index (meta_value(20));

Run this in phpMyAdmin or WP-CLI: wp db query "ALTER TABLE wp_postmeta ADD INDEX..."

Need this built properly? Describe the project and get a free estimate.

The Hooks Panel

Query Monitor’s Hooks panel shows every WordPress action and filter that fired, in order. This is useful for:

  • Finding which hook a plugin is using for a specific behaviour
  • Checking the priority order of hooked functions
  • Verifying your own hook registrations are firing

Filter the hooks list by hook name to focus on what you care about. The “Callback” column shows which function is hooked and which file it is in.

The HTTP API Calls Panel

This shows all external HTTP requests made during page generation – calls to payment gateway APIs, weather APIs, remote image services, etc. Each shows the URL, method, response code, and time taken.

Slow HTTP calls are often the single biggest contributor to page generation time. A call to an external API that takes 800ms adds 800ms to every page load for every visitor. Solutions:

  • Cache the API response with a transient: set_transient('api_key', $response, HOUR_IN_SECONDS);
  • Move the call to a background process using WP-Cron instead of running it synchronously on page load
  • Use a faster API endpoint or CDN-backed version

PHP Errors and Warnings

Query Monitor’s PHP Errors panel catches notices, warnings, and deprecation messages that do not appear in the browser but do slow down PHP execution. A page generating 200 PHP notices is slower than one generating none, even if the notices are invisible. After fixing obvious errors, check whether notices are being suppressed by your error_reporting setting – suppressed notices still consume processing time.

Keep Reading

Previous Post WP All Import Duplicate Detection: Getting It Right Every Time Next Post Using Query Monitor to Debug WordPress Hooks and Plugin Conflicts

Need Help With Your WordPress Site?

If you need help with WordPress fixes, plugin issues, theme customization, or development work, feel free to get in touch.

Get a Free Estimate