When a WordPress page is slow, most developers reach for Google PageSpeed Insights or GTmetrix. These tools tell you what's slow from the outside — file sizes, render-blocking resources, connection times. But they can't tell you why WordPress took 800ms to generate the HTML that was then delivered.
Query Monitor fills that gap. It's a free WordPress plugin that instruments the page generation process itself — showing you every database query, every hook that fired, every PHP script that ran, every external HTTP request, every template file loaded, and exactly how long each took.
It's the most powerful free WordPress debugging and performance tool available. This guide teaches you how to use it effectively to diagnose and fix performance problems at the application level.
After activation, an admin toolbar item appears at the top of every page — both on the front end (when logged in) and in wp-admin. This is your Query Monitor dashboard trigger.
Access: Click any Query Monitor item in the admin toolbar to open the full panel.
Who sees it: By default, only Administrators see Query Monitor's output. This is important — your site visitors don't see it, even when you're debugging live.
Query Monitor's panel attaches to the bottom of the page (like browser DevTools). It has several tabs, each addressing a different aspect of page performance. Below we cover the most important ones in detail.
The Queries tab shows every database query executed during page generation.
What to Look For:
Individual query details:
Example: Diagnosing an N+1 Query Problem
An N+1 query problem occurs when code fetches a list of objects (1 query) then fetches related data for each object individually (N additional queries). For a list of 50 posts that each need their author's name, this produces 51 queries instead of 1 or 2.
In Query Monitor, you'll see the same query pattern repeated many times with different IDs — a clear N+1 signature.
Fix: Use WP_Query with the fields argument, or use get_posts() with update_post_meta_cache and update_post_term_cache set to true to pre-populate caches.
The Hooks tab shows every WordPress action and filter that fired during page generation, in execution order, with the number of callbacks attached to each.
What to Look For:
the_content filter is accumulating 200ms, some callback attached to it is the bottleneck.Shows every external HTTP request made during page generation — calls to external APIs, remote services, and CDNs initiated by WordPress or plugins.
What to Look For:
Fixing Slow External HTTP Calls — Cache API responses:
If a plugin makes an external API call on every page load, its data should be cached using WordPress transients:
function get_external_data() {
$cached = get_transient( 'my_external_data' );
if ( $cached !== false ) {
return $cached;
}
$response = wp_remote_get( 'https://api.external.com/data' );
$data = json_decode( wp_remote_retrieve_body( $response ) );
set_transient( 'my_external_data', $data, HOUR_IN_SECONDS );
return $data;
}
Shows the template hierarchy — which template files WordPress evaluated and loaded to render the page.
What to Look For:
Lists every JavaScript and CSS file enqueued for the page — handle, source URL, dependencies, and whether loaded in header or footer.
What to Look For:
<head> without defer or async are render-blocking. The Scripts tab makes these visible.Shows all PHP errors, warnings, and notices generated during page generation — even ones suppressed by error reporting configuration.
What to Look For:
The Component column shows which plugin or theme generated the error, making it easy to identify the responsible code.
Request tab shows the parsed WordPress query — query type (single post, archive, search, etc.), queried object details, query variables, and the rewrite rule that matched. Useful for debugging permalink issues, custom query var problems, or unexpected page type detection.
Environment tab provides comprehensive technical information about the server:
For production debugging (investigating a problem on a live site without affecting visitors), Query Monitor can be shown only to specific users or via a secret cookie.
Show Only for Admins (Default)
By default, Query Monitor only displays for logged-in users with the view_query_monitor capability (Administrators have this automatically).
Authenticate via Cookie (Development)
For debugging when not logged in, set a cookie qm_auth with the value of a password hash. Add to wp-config.php:
define( 'QM_COOKIE_HASH', wp_hash( 'my-secret-phrase' ) );
Then set the cookie in your browser and Query Monitor appears even when logged out.
| Tool | Type | Best For | Setup |
|---|---|---|---|
| Query Monitor | Free WordPress plugin | WordPress-level profiling: queries, hooks, HTTP calls, templates | Zero configuration |
| Xdebug | PHP extension | Line-level PHP profiling, step debugging, function tracing | Requires server config |
| New Relic / Datadog APM | Enterprise APM | Continuous production monitoring, transaction tracing, alerting | Complex setup, paid |
When a WordPress page is slow, this is the diagnostic process with Query Monitor:
Step 1: Measure baseline
Load the page and note Query Monitor's summary: total queries, total query time, total page generation time.
Step 2: Identify the dominant cost
Is most time in database queries? In hook callbacks? In HTTP API calls? The summary bar shows the breakdown.
Step 3: Drill into the biggest contributor
Step 4: Identify the responsible component
The "Caller" column in Queries, "Component" in Hooks — tells you which plugin, theme, or WordPress core is responsible.
Step 5: Fix and verify
Make the fix (add caching, optimise the query, fix N+1) and reload. Query Monitor shows the before/after immediately.
| Tab | Shows | Key Signal |
|---|---|---|
| Queries | Every database query | Duplicates, slow queries (>50ms), high total count |
| Hooks | Actions and filters fired | Slow callbacks, unexpected hooks |
| HTTP API | External HTTP requests | Slow/uncached API calls, failed requests |
| Template | Template files loaded | Wrong template loading, plugin overrides |
| Scripts & Styles | Enqueued JS/CSS files | Duplicate libraries, render-blocking scripts |
| PHP Errors | Errors, warnings, notices | Deprecated code, undefined variables |
| Request | WordPress query vars | Permalink issues, wrong query type detection |
| Environment | PHP, server, WP config | OPcache off, low memory limit, old PHP |
view_query_monitor capability (Administrators by default), and even when collecting data it adds minimal overhead (under 5ms typically). It can alert you to errors and performance regressions as they appear on your live site.
Query Monitor is one of the first plugins every WordPress developer should install. It turns performance diagnosis from guesswork into evidence-based investigation — you see exactly what's slow, where in the code it comes from, and can verify improvements immediately.
Install it now, even if your site feels fast. Understanding what's happening under the hood — how many queries your pages make, what hooks fire, which plugins make external calls — builds the intuition that separates developers who write performant WordPress code from those who don't.
Contact us for professional WordPress performance optimisation