Skip to content
Arrow keys to move, Enter to open, Esc to closeAll results
Performance · Guides

How to Use Query Monitor to Find Slow Plugins

Install Query Monitor on a staging copy, read its panels in the right order, and trace slow queries, duplicate queries and slow HTTP calls back to the plugin responsible.

Written by
WPresident Editorial
Topic
Performance

Someone tells you the site is slow. You open the plugins screen and count thirty-odd active plugins, a theme with its own bundled extras, and a couple of must-use files nobody remembers adding. The usual advice is to deactivate plugins one at a time until the site speeds up. That works eventually, but it is slow, it is risky on a live site, and it only tells you that removing something helped. It does not tell you what the plugin was doing, or whether a setting could have fixed it.

Query Monitor replaces that guessing with evidence. It is a free developer plugin that records what WordPress did while building one specific request: every database query, every outbound HTTP call, every hook callback, every enqueued script and style, every PHP notice, and which plugin, theme or core component was responsible for each. The single most important idea in this guide is that attribution. Query Monitor does not tell you a plugin is bad. It tells you, for this request, who ran which query, who made which remote call and how long each one took. You supply the judgment about whether that cost is fair for what the plugin gives you.

That distinction matters because the raw numbers are easy to misread. A page with a hundred queries can be perfectly healthy, for example the admin screen of a large shop plugin. A page with twelve queries can be in real trouble if one of them scans a huge table. A red toolbar can mean a harmless deprecation notice. A staging site with a tiny database can make a terrible query look instant. So the skill is not knowing where the panels are. It is reading them in a sensible order, on a copy of the site that behaves like the real one, and confirming a suspicion before you act on it.

This guide walks the whole loop. You will set up a staging copy that tells the truth, install the plugin and understand its database drop-in, read the toolbar and the Overview without panic, and use the Timeline to see where a request spends its time. Then you will go through the panels that find real problems: queries grouped by component, duplicate queries and the N+1 pattern, slow queries, autoloaded options, slow external HTTP calls, hooks, assets, PHP errors and response headers. After that comes the part most tutorials skip: what Query Monitor cannot see (cron, for example), how to confirm a culprit by experiment, what to do next (remove, configure, cache or replace) and how to keep a fix log so the next person can see what changed and why.

Two boundaries are worth stating up front. First, this is a general guide, not a test report. There are no benchmark figures here and no claims about how much any particular plugin costs, because cost depends on your data, your host, your PHP version, your caching and your traffic. Where a number appears in an example, it is an illustration of how to read a panel, not a measurement. Second, Query Monitor is a diagnostic tool for development and staging. It exposes SQL, file paths and internal structure to anyone who can see its output, so the habits in this guide assume you work on a copy of the site and carry the verified fix to production afterwards.

You do not need to be a developer. You need an administrator login on a staging copy, and for a few steps a terminal with WP-CLI or a database client. The code snippets are short and explained. By the end you will be able to hand a plugin author or your developer a precise report instead of the vague complaint that the site feels slow.

Key points

  • Query Monitor shows what one request did and which plugin, theme or core component was responsible; it ranks suspects but does not deliver a verdict.
  • Test on a staging copy with production-sized data, the same PHP version and the same object cache, or the numbers will mislead you.
  • Read in order: toolbar and Overview, Timeline, queries by component, duplicates and slow queries, then HTTP calls, hooks, assets and errors.
  • The N+1 pattern hides as many near-identical queries from one caller; Duplicate Queries only matches identical SQL text, so also check Queries by Caller.
  • Query Monitor is not a profiler and cannot see cron, so use WP-CLI for scheduled events and confirm every suspect by deactivating it and reloading.
  • Fix in a safe order (remove, configure, cache, replace), change one thing at a time and record it in a fix log with before and after readings.

What Query Monitor is, and what it is not

Query Monitor is a debugging plugin that adds a menu to the admin toolbar and a set of panels for the page you are looking at. While WordPress builds that page, the plugin collects data about queries, HTTP calls, hooks, assets, errors and more, then shows it to you once the page has finished. The data lives for that one request. Its own documentation is explicit that historical information is not available, so if you want to compare yesterday with today, you have to write the numbers down yourself.

The toolbar shows four figures in a fixed order: page generation time in seconds, peak memory, total SQL query time in seconds and the total number of SQL queries. Clicking the top of the menu opens the Overview panel. Everything else hangs off the sidebar of the panel that opens. In recent releases the panels are drawn in the browser rather than on the server, and a Timeline panel was added, so if what you see differs from older screenshots online, check which version you have installed.

The feature that earns the plugin its place is component attribution. Every query, hook callback and HTTP call has a call stack behind it, the chain of functions that led to it. Query Monitor works from that stack to decide whether the responsible code lives in WordPress core, a plugin, a theme or a must-use file, and then groups results that way. This is why you can ask the plugin for queries by component and see a ranked list of who spent the most database time.

Attribution points at who called, not always at who is to blame. Imagine a plugin that changes the main query through a filter so it sorts by a custom field. The query itself is run by core inside the template, so it may be credited to core or the theme even though the plugin shaped it. That is why you read the call stack and the Hooks panel as well, rather than trusting the component label alone.

Equally important is what the plugin does not do. It is not a profiler. It does not tell you how many milliseconds each PHP function consumed, so a plugin that burns CPU in a tight loop without touching the database or the network will not show up as expensive. It is not a load tester, so it says nothing about how the site behaves with fifty visitors at once. And it has a small cost of its own. The project describes the impact on page generation as small, but it notes that memory use rises on pages with hundreds of queries because stack traces are stored. Treat absolute numbers as inflated and compare relative ones, always on the same site, with the plugin in the same state.

Within those limits it covers the causes that show up again and again on WordPress sites: too many or too slow database queries, remote calls that make PHP wait, assets loaded where they are not needed, errors written to logs on every request and bulky data loaded on every page. Treat it as a ranking and attribution tool, and confirm what it suggests with simple experiments.

What Query Monitor answers and what needs another tool

Query Monitor answersNeeds another tool
Database workWhich queries ran, how long they took and which component called themHow the database server behaves under load across many requests
PHP timeTiming only for code you wrap yourself with its timer actionsTime per function across the whole request needs a profiler
Remote callsEach server-side HTTP call, its response code and how long it tookLatency inside the vendor service itself
HistoryNothing is stored between requestsMonitoring or logging that records many requests over days
TrafficOne request at a time as an administratorA load test or real-user monitoring for concurrency
Use Query Monitor for attribution inside one request, and reach for other tools when the question is about CPU time, history or load.

Build a test bench that tells the truth

Most disappointing Query Monitor sessions fail before the plugin is installed. The site you test on does not behave like the site your visitors use, so the conclusions do not transfer. Spend an hour on the bench and the results become trustworthy.

Start with the data. Query performance depends on table size, and a staging site seeded with ten sample posts will make every query look fast. Copy the production database to staging, with files, so the tables have realistic row counts. That copy contains personal data, especially on shops and membership sites, so treat it like production: restrict who can reach it, keep it out of search engines, and where your policies require it, anonymise customer details. On a store, also switch payment gateways to test mode and stop the staging copy from sending real emails.

Next, match the stack. Use the same PHP version, the same web server type and, importantly, the same object cache. If production uses a persistent object cache such as Redis or Memcached and staging does not, staging will run queries that production never sends to the database, and your duplicate and query-count readings will be wrong in the pessimistic direction. If it is the other way round, you will miss problems entirely. The same applies to the plugin set: staging should have exactly the plugins and settings that production has, no more and no fewer.

Then control the cache state. Page caches usually skip logged-in administrators, so you will be profiling the uncached path, which is correct for admin screens, carts, checkouts, search results and anything personalised. It is also the path every cache miss takes for a visitor. Make a habit of loading each test URL several times and recording a later load, once data and object caches are warm, and separately noting the first cold load after a cache flush, because slow cold loads are a real problem for the first visitor after a purge.

Finally, decide the requests. Pick a short fixed list: the front page, a typical post or product, a category or shop archive, search, the cart and checkout if you sell, the dashboard, and the one admin screen people complain about. Always test the same URLs, as the same user role, so before and after readings can be compared. Write the list down; it anchors your fix log later.

One more precaution applies to staging and production alike. Some tasks, such as large imports, backups and security scans, are poor candidates for being observed, because the plugin would collect data for an enormous request. Query Monitor provides a hook, qm/cease, that stops collection for the rest of a request, discards what was gathered and skips output. It is intended for exactly those jobs.

The layers of a faithful test bench

The requestA fixed list of URLs, always loaded as the same user role.
Cache stateWarm for normal readings, plus a recorded cold load after a flush.
Plugins and settingsThe identical plugin set, theme and configuration as production.
StackSame PHP version, web server type and object cache backend.
DataA production-sized database copy, protected like production and with email and payments disabled.
Each layer should match production, otherwise the numbers describe a site your visitors never use.

Install it, understand permissions and the db.php drop-in

Install Query Monitor like any plugin: search for it on the Plugins, Add New screen, or use WP-CLI on the staging server.

$ wp plugin install query-monitor --activate

When it is active and you are logged in as an administrator, a new menu appears in the admin toolbar with the four figures described earlier. By default, output is shown to administrators on a single site and to super admins on multisite. The plugin checks a capability named view_query_monitor, which matters on platforms where administrators do not automatically hold it. If you cannot see the menu, check that you are logged in as the right role and that the toolbar is enabled for your profile. For logged-out visitors or non-administrators, the Settings panel offers an authentication cookie, which is the supported way to see output on those requests. Read the current documentation for the exact steps, and remove the cookie when you finish.

The second thing to understand is the drop-in. On activation, Query Monitor tries to place a symlink named db.php in the wp-content directory, pointing at a file inside the plugin. WordPress treats that file as a database drop-in, and it is what lets the plugin report extended query details: the number of rows returned, full stack traces and query errors. Without it the plugin still runs, but you lose those details, and the attribution you came for gets thinner.

The symlink can fail for a few reasons: PHP cannot write to wp-content, another db.php already exists, or a site moved from another host carries a symlink that points to a path that no longer exists. Plugins that use their own database drop-in, such as some caching and database tools, can conflict, and WordPress allows only one file at that location, so there is no workaround on the plugin side. Check the state from the shell.

$ ls -l wp-content/db.php

A healthy result shows an arrow pointing into the query-monitor plugin directory. If the file is missing, the plugin provides a WP-CLI command, wp qm enable, to recreate it, and a constant, QM_DB_SYMLINK, that you can set to false if you do not want the symlink created. You can also make wp-content writable, deactivate and reactivate the plugin.

Finally, learn the off switch before you need it. A constant in wp-config.php turns the plugin off without deleting it, which is useful when you want to confirm that a symptom is not caused by the monitoring itself.

define( 'QM_DISABLED', true );

Remove the line, or set it to false, to turn the plugin back on. Do not leave it running on production as a permanent fixture. It is built for development, and the SQL and paths it reveals are what you do not want a stranger to see if a permission is ever misconfigured.

wordpress.org
The Query Monitor page in the WordPress plugin directory, showing frequently asked questions about add-on plugins, clickable stack traces and hosting.
The plugin directory page is the place to confirm current requirements, the supported version and the FAQ before you install.

Read the toolbar and Overview without panic

The first reading is the cheapest and the one people over-interpret. The toolbar gives you page generation time, peak memory, total SQL time and total SQL count. Treat them as a baseline for that URL, not as a grade. A checkout page legitimately runs more queries than a blog post, and an admin screen for a large shop plugin can run many more than either. What you want to know is whether the numbers for a given page are unusual compared with the same page last week, or with a similar page that feels fast.

The most useful single comparison is SQL time against page generation time. As an illustration only, if a page takes about two seconds to generate and the queries add up to a fifth of a second, then the database is not where the time went, and spending an afternoon on query tuning would be wasted. The documentation makes the same point: HTTP API calls and block rendering can add more time than queries do. Work out which bucket holds the time before you open the panel for it.

Next, look at memory. The Overview shows peak memory against the PHP limit. A request that sits close to its limit is one slow deploy or one extra plugin away from a fatal error, and large memory use often travels with large data loaded on every request, which is the autoloaded options story later in this guide.

The Overview also reports on the object cache. If it says that an external object cache is not in use, the site is relying on the per-request cache only, which is empty at the start of every request. A persistent object cache such as Redis or Memcached lets repeated lookups across requests skip the database. Query Monitor shows a hit rate when it can, but its own help page notes quirks with certain cache drop-ins, so treat the figure as a hint, not a target to maximise.

Then calm down about colours. The toolbar highlights errors in red or orange, and individual panels flag things such as slow queries. Those flags tell you where to look, not what is wrong. A deprecation notice from an active plugin is worth noting but rarely explains a slow page. A single query slightly over the slow threshold on an admin screen nobody visits is usually not worth a ticket. Ask of every flag: does this happen on a path real users hit, and does it happen every time?

A good habit is to write one line per URL: the four numbers, the object cache state and the top component by query time. It gives you a map of the site, and the later panels become easier to read because you know what normal looks like.

How loudly to react to what you see

How to read this: each row is one option, and its dot shows where it sits between Usually fine and Fix first. Placement is an editorial judgement, not a measurement.

  1. 1Many queries on a heavy admin screenCompare with the same screen over time before worrying.
  2. 2Deprecation notice from an active pluginReport it, but it rarely explains slowness.
  3. 3One query just over the slow thresholdMatters if it runs on every page.
  4. 4Writes on a front-end page viewFind out what is being saved and why.
  5. 5Same caller firing hundreds of queriesThe classic N+1 shape.
  6. 6Blocking remote call on every requestVisitors wait on a third party.
An editorial guide to priority, not a measurement: the further right, the sooner it deserves a fix.

Use the Timeline to see where the request spends its time

If your version includes the Timeline panel, open it before any other. It plots the events of one page load on a horizontal time axis: database queries, HTTP API requests, PHP errors, your own timers, log entries and other notable events, each as a bar whose position shows when it started and whose length shows how long it took. Filter by component or by category, and click an event label to jump to its entry in the related panel.

Three shapes are worth learning to recognise. The first is a long bar: one operation that takes a large share of the request, which is the obvious thing to optimise or remove. The second is a staircase of bars that run one after another rather than overlapping, which indicates serial work. Several remote calls in a row, each waiting for the previous one, look exactly like this, and PHP will happily wait through all of them. The third is a dense cluster of short bars. Some clustering is normal around the init action and during template rendering, so only worry when a single component owns most of a cluster.

The Timeline also shows you what is missing. Time that is not covered by any bar is time spent in PHP or waiting on something Query Monitor does not record. A page with a large empty stretch and healthy-looking queries is telling you that the cost is probably computation, template logic or code that never touches the database, and that is the moment to reach for a profiler or to wrap suspect code with Query Monitor timers, covered later.

It helps to know the order in which WordPress does things, because a component’s work tends to cluster around the hook it uses. Plugins load first, then the theme sets up, then init runs, and later the main query runs, the template is chosen and rendered and the footer closes the page. Work done on plugins_loaded or init happens on nearly every request, including ones that never needed that feature. Work done late, inside a template or a shortcode, happens only where the content calls for it. A plugin that does heavy work early for every page is a different problem from one that does heavy work only on the page that uses it, and the Timeline shows you which kind you have.

A few cautions apply. The panel shows one request, so one unlucky bar might be a cold cache or a network hiccup; reload and see whether it repeats. Components can overlap in time, so do not add up bar lengths and expect the request time. On an older release without a Timeline, sort the Queries and HTTP panels by time instead.

querymonitor.com
The Query Monitor documentation page for the Timeline panel, explaining how events from a page load are plotted on a time axis.
The documentation for the Timeline panel explains how to read bars, clusters and serial work.

Attribute database cost with Queries by Component and Caller

The Queries panel is the part of Query Monitor most people open first, and it has several views that answer different questions. The main list shows every SQL statement in the request with its type, caller, component, rows and time, and flags statements over the slow threshold or ones that returned an error. You can filter by query type, component and caller. The Non-SELECT filter is easy to overlook and valuable, because it isolates writes. A page that only displays content should rarely insert or update anything, so writes on an ordinary front-end view deserve an explanation.

Queries by Component is the ranking you came for. It groups queries by plugin, theme or core and sorts by total time, so the biggest database consumer is at the top. Core will usually sit near the top, because WordPress builds the page. That is normal. What you are looking for is a plugin or theme whose share is out of proportion to what it does on this page. A contact form plugin with a large share on a page that has no form is a candidate, and so is an analytics or security plugin that runs the heaviest queries on every request.

Read total time, not query count. As an illustration, a component that runs two hundred queries at a fraction of a millisecond each can cost less than another that runs three queries at tens of milliseconds each. The count matters in a different way: a very high count from one caller is the signature of a loop, which the next section covers. Use time to decide who is expensive and count to decide what kind of problem it is.

Queries by Caller groups by the function that issued the statement, with totals for count and time broken down by query type. Clicking a caller name opens the main list filtered to that caller, so you can read its statements together. This is the best view for spotting a theme function or a shortcode that queries the same table repeatedly while a template renders.

Once a statement looks suspicious, expand its call stack. Frames are listed from the code that ran the query down to the code that started the request. The first frame inside a plugin or theme folder is usually where the responsibility starts. If the stack shows core functions with a plugin callback further down, a filter or hook is steering core, and the Hooks panel can then tell you which callback is attached. If your editor is configured in the Settings panel, stack frames can be made clickable so you can jump straight to the file.

Finish every attribution with an experiment. Deactivate the suspected plugin on staging, reload the same URL as the same user and compare the component table. If the total drops by roughly what the plugin was charged, the attribution holds. If it barely moves, the cost belongs elsewhere, and you have avoided a wrong fix.

querymonitor.com
The Query Monitor documentation page for the database queries panel, describing the all queries, queries by caller, queries by component, duplicate queries and slow queries views.
The database queries documentation lists each view, which together move you from a flat list to a ranked list of culprits.

Find duplicate queries and N+1 patterns

An N+1 pattern is what happens when code fetches a list with one query and then runs one extra query per item to get a detail, so a list of fifty items costs fifty-one queries. It is the most common way a plugin or theme turns a small amount of data into a slow page, and Query Monitor has two separate ways to catch it.

The first is the Duplicate Queries view. It lists statements that ran more than once in the request with identical text, and shows how many times, which callers and which components were responsible, with a column that points at the likely sources. Repeats often mean a query sits in a loop when it could run once and be reused. The important limit is that matching is on the exact statement, so queries that differ only by an ID are not duplicates as far as this view is concerned.

That is why the second method matters. A true N+1 produces many near-identical statements with different IDs. They will not appear in Duplicate Queries, but they will appear in Queries by Caller as one caller with a surprisingly high count. Click it, read the filtered list, and the pattern is obvious. A very common shape in WordPress is a metadata lookup. Core primes the meta cache with one statement that selects post_id, meta_key and meta_value from the postmeta table with an IN list. If you see dozens of those statements, each with a single ID in the list, something is reading meta for posts one at a time, usually because the IDs came from a source that did not prime the cache, such as a custom query or a WP_Query call that turned meta priming off.

// N+1 shape: one meta query per post when the cache was not primed
foreach ( $post_ids as $post_id ) {
    $price = get_post_meta( $post_id, '_example_price', true );
}

// Fix: prime the meta cache for every ID with one query, then read as before
update_meta_cache( 'post', $post_ids );
foreach ( $post_ids as $post_id ) {
    $price = get_post_meta( $post_id, '_example_price', true );
}

Not every duplicate is a problem. A statement that runs twice on a page is a rounding error compared with one that runs eighty times. Rank by count multiplied by time, and ignore the rest. It is also worth knowing why duplicates survive a persistent object cache: core functions that use the cache will not repeat a database query, but code that calls the database object directly bypasses the cache and repeats the work every time. Duplicates therefore point you toward code that does not use the caching helpers.

What you do next depends on who owns the code. In your own theme or custom plugin, fix the loop. In a third-party plugin, collect the evidence, namely the statement, the count, the call stack and the plugin version, and look for a setting that disables the feature doing the looping. Then report it to the vendor, and consider whether a lighter alternative exists if the cost is not acceptable.

Tracing a repeated query to its source

  1. Spot the repeatDuplicate Queries for identical text, or a high count in Queries by Caller for near-identical text.
  2. Open the callerClick through to the filtered list and read the statements together.
  3. Read the call stackFind the first frame that sits inside a plugin or theme folder.
  4. Check the hooksIf core appears in the stack, look in the Hooks panel for the callback steering it.
  5. Confirm by experimentDeactivate the suspect on staging and reload the same URL.
  6. Choose the fixFix the loop yourself, change a setting, report it with evidence or replace the plugin.
Follow the evidence from the flagged query to a specific plugin or theme function before deciding anything.

Slow queries: the threshold, EXPLAIN and the staging trap

The Slow Queries view lists statements whose time exceeds a threshold. The default is a constant named QM_DB_EXPENSIVE, which ships as 0.05, and the plugin reports times in seconds. You can change it in wp-config.php if you want a stricter or looser filter on a particular site.

define( 'QM_DB_EXPENSIVE', 0.1 );

Raise the threshold to see only the worst offenders on a busy admin screen, and lower it when hunting many small costs. Either way, a flagged query is a candidate, not a verdict. Ask three questions. Does it run on a path real users take? Does it run every time or only after a cache flush? And what does it do, in terms of table, filter and sort?

Reading the statement tells you a lot. A query that filters the postmeta table by meta_value is a common culprit, because core indexes post_id and meta_key but not the value. A search with a leading wildcard in a LIKE condition cannot use a normal index. Random ordering forces the database to sort the whole result. A large number in the rows column means the statement pulled far more data than the page needed. Joins across several big tables multiply all of these.

To go beyond guessing, run EXPLAIN on a copy of the database, in a database client or through WP-CLI, using the statement copied from the panel.

EXPLAIN SELECT post_id FROM wp_postmeta WHERE meta_key = '_example_flag' AND meta_value = '1';

In the output, a type of ALL means a full table scan. A key of NULL means no index was chosen. The rows estimate tells you how much the server expects to read, and Extra may mention a filesort or a temporary table, both of which signal extra work. Adjust the table prefix to match your site, and run it on staging only.

Two traps catch beginners. The first is the staging trap: a small test database makes every query look fast, so a statement that will hurt with a production-sized table passes unnoticed. This is why the test bench starts with real data. The second is the cold start: the first execution of a statement after a restart or a big import can be slow because the data is not in memory yet, and the second is fast. Re-run before you blame the plugin.

If a slow statement belongs to a third-party table with no usable index, resist the urge to add one by hand on production. Plugin updates and migrations can rebuild or drop what you add. Report the statement and the EXPLAIN output to the vendor first, test any index on staging with a backup, and write it down in the fix log so the next update does not silently undo it.

A statement is flagged slow: what next?

What is the flagged statement doing?
It hits a core table and a plugin shaped the argumentsChange the plugin setting or the query arguments, such as removing an unneeded sort or custom field filter.
It scans a plugin table and EXPLAIN shows no usable indexReport it to the vendor with the statement and output, update, and only then consider an index you maintain.
The table is huge because of old dataPrune or archive on staging first, with a backup, then repeat on production.
It only runs on a rarely used admin screenRecord it in the fix log and leave it unless people complain.
Match the fix to who controls the query and why it is slow.

Autoloaded options and transients

The options table stores settings as rows, and each row has an autoload flag. Rows flagged for autoload are fetched in a single query early in every request and kept in memory, whether or not the current page needs them. That is a sensible design for small settings, and a quiet performance problem when plugins store large blobs there: caches, logs, serialized configuration and leftovers from plugins long since removed.

Query Monitor shows the symptom. In the Queries panel, find the statement that selects option names and values from the options table where autoload is on. It is credited to core, and its rows column tells you how many options were loaded. A very large count, together with high memory in the Overview, suggests bloat. Query Monitor will not tell you which options are large, so use WP-CLI for the size.

$ wp option list --autoload=on --format=total_bytes
$ wp option list --autoload=on --fields=option_name,size_bytes --format=csv | sort -t, -k2 -n | tail -n 20

The first command gives the combined size of autoloaded options in bytes. The second lists the twenty largest, with the biggest last. Many option names begin with the prefix of the plugin that created them, which makes attribution straightforward. A persistent object cache does not make a large autoload set free: the combined blob still has to be fetched and unpacked on every request.

Be careful with fixes. Do not delete options of an active plugin, and do not delete anything you cannot name. Start with obvious leftovers from plugins you uninstalled long ago, and test removal on staging with a backup. Better still, look for a cleanup routine in the plugin itself, or ask the vendor why a cache lives in an autoloaded option. Recent WordPress versions also have a Site Health check for autoloaded options, a useful second opinion.

Transients are the related problem. The Transients panel lists every transient written during the request, with its name, expiry, approximate size and source. Transients should be set infrequently, so a write on every page view is suspicious: either the code is saving unnecessarily, or the value expires immediately and is regenerated each time. Where is it stored? With a persistent object cache, transients live in the cache. Without one, they become rows in the options table, and a transient saved with no expiry is autoloaded, which feeds straight back into the bloat above.

Slow external HTTP calls that make PHP wait

When a plugin calls another server from PHP, the request usually stops and waits for the answer. Visitors see nothing until every call has finished. Query Monitor lists these server-side calls in its HTTP API requests panel, with the response code, the responsible component and the time taken, and it raises an alert for failed requests. The same calls appear as bars on the Timeline, which is where serial waiting is easiest to see.

The usual suspects are licence and update checks, feeds fetched for dashboard widgets, remote logging, analytics events and calls to payment, shipping or marketing services. They matter most on admin screens, where one slow licence server can slow every page.

Read the panel with three questions. Does the call happen on every request or only once in a while? Does it block rendering, or could it be done later? And what happens when the remote service is down? A call without a sensible timeout can hold a request for as long as the default allows, and core’s helpers use a default of five seconds unless the code overrides it, so check your version. On staging, a firewall or the WP_HTTP_BLOCK_EXTERNAL constant can make calls fail that succeed in production, so separate real slowness from environmental failure before concluding anything.

The fixes follow the same order every time: remove the feature, lengthen the interval between calls, cache the result, lower the timeout or move the call out of the page request. A fire-and-forget call, such as sending an analytics event, can be made non-blocking. For data you control, a short transient wrapper is often enough.

function example_get_remote_data() {
    $data = get_transient( 'example_remote_data' );
    if ( false !== $data ) {
        return $data;
    }
    $response = wp_remote_get( example_endpoint(), array( 'timeout' => 3 ) );
    if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
        set_transient( 'example_remote_data', array(), 5 * MINUTE_IN_SECONDS );
        return array();
    }
    $data = json_decode( wp_remote_retrieve_body( $response ), true );
    $data = is_array( $data ) ? $data : array();
    set_transient( 'example_remote_data', $data, HOUR_IN_SECONDS );
    return $data;
}

Caching the failure for a few minutes is deliberate: it stops a dead service from being retried, and waited on, by every request.

How serial remote calls stack up in one admin request

StartWordPress boots and plugins load.
EarlyA licence plugin calls its server and PHP waits for the reply.
MiddleA dashboard widget fetches a remote feed and PHP waits again.
LateAn analytics plugin posts an event and waits for confirmation.
EndThe page is finally sent, after every wait has been added together.
An illustration of the shape to look for, not a measurement: each wait adds to the next.

Hooks, assets, PHP errors and response headers

These four panels rarely explain a very slow page on their own, but they find the cheap wins, and they show how a plugin behaves everywhere, not only in the database.

The Hooks panel lists the actions and filters that fired, with every callback attached, its priority and its component. Use it to answer a specific question: who is attached to init, to wp_head or to template_redirect, and is any of it surprising? You can search by hook name and filter by component. It does not show time per callback, so use it to find owners and order, not to measure. It also warns when something is attached to the all hook, which fires for every action and filter and carries a real cost; that should never be present on a production site.

The Scripts and Styles panels list every enqueued file with its dependencies, its dependents and the component that registered it. They do not affect server time much, but they affect what visitors download. Look for a plugin that loads assets on every page when its feature appears on one. The panels also flag broken dependencies, which WordPress otherwise drops silently. The usual fix is a setting in the plugin that limits where it loads, or a conditional rule that dequeues the asset where it is not needed.

The PHP Errors panel groups notices, warnings and deprecations by unique call point with a count, and credits a component to each. A deprecation notice is not an emergency, but the panel makes a hidden cost visible: each error may be written to a log on every request depending on server configuration, and a plugin that triggers dozens per page adds that work to every load. A Doing It Wrong panel works the same way for incorrect API usage. Note them, update the plugin and report persistent ones. Do not hide them by lowering error reporting without understanding why they occur.

Finally, the Headers panels show the request headers the browser sent and the response headers the server returned. Use the response side to check caching: Cache-Control, Expires and ETag tell you whether a page is allowed to be cached at all. A plugin that sends no-cache headers on pages you expected to be cached is a quiet reason for slow visits that Query Monitor would otherwise never mention.

What the toolbar cannot show: cron, Ajax, REST and your own timers

Query Monitor reports on the request in front of you. Anything that does not produce a page you can open as an administrator needs another route, and the main gap is WP-Cron. WordPress runs scheduled events in a separate request, so their queries and remote calls never appear in the data of the page that triggered them. Use WP-CLI to see what is scheduled and run due events yourself while you time them.

$ wp cron event list
$ time wp cron event run --due-now

Warning signs in the list are a hook scheduled very frequently, the same hook scheduled many times over, or a job that belongs to a plugin you removed. Run the due events on staging, note how long they take, and look at the plugin that owns the slowest one. Plugins with their own job queues usually have their own status screen, so check there too.

Ajax and REST requests are covered partly. Ajax responses carry debugging information in their headers and send PHP errors to the browser console. Authenticated REST responses include overview headers such as x-qm-overview-time-taken and x-qm-php-errors-count, as long as the user can view Query Monitor output and the request is authenticated with a nonce or an application password. Requesting an enveloped response adds a qm property with queries, HTTP calls and transients. Open the browser network tab on the request that feels slow and read the headers there.

For code you own, or a temporary edit on staging, you can make Query Monitor measure exactly what you want with timers and log entries, which then appear in the Timings and Logs panels and on the Timeline.

do_action( 'qm/start', 'build-menu' );
example_build_menu();
do_action( 'qm/stop', 'build-menu' );

do_action( 'qm/debug', 'Menu built' );

Remove timers and logs once you have your answer. If the question is about CPU time spread across many functions, that is the point to bring in a profiler.

What to do next: remove, configure, cache or replace, and keep a fix log

Finding the culprit is half the job. For each confirmed finding, work down the options in order of risk. Remove first: if nobody can say what a plugin does, deactivate it on staging, watch for breakage and, after a backup, delete it. Configure second: most heavy plugins have modules, schedules and loading rules, and turning off what you do not use is cheap and reversible. Cache third: if the result is the same for most visitors and changes rarely, store it with a transient or let the object cache do it, accepting that stale data is the price. Replace last: a lighter alternative may exist, but migration touches data, shortcodes and settings, so test it as carefully as a new build.

Whatever you choose, change one thing at a time. Take the baseline readings for your fixed URL list, make the change, reload the same URLs as the same user, and compare. If the readings move, keep the change and record it. If they do not, roll back and note that the suspect was innocent. Repeat the process after major plugin updates, because a new release can add or remove costs.

The fix log is what makes this a process rather than an afternoon. Keep one entry per change, in a plain file your team can read.

date:
request: front page, logged in as administrator, warm cache, third load
build: WordPress and PHP versions, theme, active plugin count, object cache yes or no
before:
  page_time_seconds:
  sql_time_seconds:
  sql_query_count:
  top_component_by_query_time:
finding: panel, evidence and suspected component
confirmed_by: deactivation test, timer or call stack
change: remove, configure, cache or replace, with details
after:
  page_time_seconds:
  sql_time_seconds:
  sql_query_count:
decision: keep, roll back or follow up
rollback: how to undo it

Keep the evidence you would give a vendor with it: the statement, the count, the call stack and the plugin version.

A plugin tops your ranking: what now?

What does the evidence say about this plugin?
Nobody can say what it doesRemove it: deactivate on staging, watch for breakage, back up, then delete.
You use it, but only some featuresConfigure it: switch off unused modules and limit where it loads.
Its output is the same for most visitorsCache it: store the result in a transient or the object cache and accept staleness.
A lighter option does the same jobReplace it, planning for data migration and a full retest.
Choose the cheapest, safest action that the evidence supports, and re-measure afterwards.

Checklist

  • Work on a staging copy with a production-sized database, never your only live site.
  • Match the PHP version, web server and object cache to production.
  • Turn off real emails and put payment gateways in test mode on staging.
  • Write down a fixed list of URLs and always test them as the same user.
  • Confirm the toolbar menu appears and the db.php symlink exists in wp-content.
  • Record the four toolbar numbers and the object cache state for each URL, warm and cold.
  • Compare SQL time with page generation time before opening any query panel.
  • Rank components by total query time, then confirm the top one by deactivating it.
  • Use the Non-SELECT filter and explain every write on a front-end page view.
  • Check Duplicate Queries and Queries by Caller for loops and N+1 patterns.
  • Run EXPLAIN on slow statements against the staging database before proposing an index.
  • Measure the size of autoloaded options and trace the biggest ones to a plugin.
  • Review HTTP API requests for calls on every request, serial waits and failures.
  • List cron events with WP-CLI and time the due ones on staging.
  • Change one thing at a time, re-test and record before and after readings in the fix log.

About this guide. This is general guidance written by WPresident Editorial from documentation and widely used practice. WPresident has not benchmarked the products or methods described. Interfaces and plan limits change, so check the vendor’s current documentation before you act. Not legal, tax or financial advice. See our editorial policy.

Frequently asked questions

Will Query Monitor slow my site down?

Its documentation describes the impact as small, but it is not zero. The plugin collects stack traces, and memory use rises on pages with hundreds of queries. Your readings are therefore slightly inflated, so compare relative numbers on the same setup. When you want an unobserved reading, set QM_DISABLED to true in wp-config.php, reload, and remove the line afterwards.

Is it safe to leave on a production site?

It is built for development and staging. Output is limited to administrators by default, but it reveals SQL, file paths and server details, so a permission mistake would be costly. If you must investigate production, do it briefly as an administrator and deactivate it afterwards. A staging copy with production-sized data is the better route.

Why can't I see the Query Monitor menu?

Check that you are logged in as an administrator, or a super admin on multisite, that the toolbar is enabled in your profile, that the plugin is active and that QM_DISABLED is not set to true. On platforms that restrict capabilities, the view_query_monitor capability must be granted. For logged-out requests, use the authentication cookie option in the Settings panel.

How many queries is too many?

There is no universal number. A heavy admin screen can run far more than a simple post, and the count alone says little. Compare the same URL over time, compare SQL time with page time, and look for one caller with a very high count or a component with a large share. Ranking by total time and by repeats beats any fixed limit.

What does the db.php message mean?

The db.php symlink in wp-content lets Query Monitor show row counts, full stack traces and query errors. It fails if wp-content is not writable, if another db.php exists or if a migrated symlink points nowhere. Fix permissions, run wp qm enable or create the link by hand. Other plugins with a database drop-in can conflict, because WordPress allows only one.

Can Query Monitor profile cron jobs?

Not directly. WP-Cron runs in a separate request and does not render a page, so its work never appears in the panels. Use WP-CLI to list and run due events and time them, then add timers or logs to code you own. For CPU questions spread across many functions, use a profiler.

Can I see what real visitors experience?

Only partly. Output is for logged-in administrators by default, which usually means the uncached path. The authentication cookie lets you view logged-out requests. Remember that visitors served from a page cache skip most PHP, so pair Query Monitor with browser developer tools and a page speed check.

Why do the numbers change between loads?

Warm and cold caches, database buffers, latency to remote services, background processes and other requests on the same server all move the figures. Load each URL several times, record a warm reading, note the cold one separately and judge by repeated patterns, not a single number.

Is Query Monitor a replacement for a profiler?

No. Its strength is attribution of queries, HTTP calls, hooks and errors within one request, quickly and without code changes. It does not show CPU time per function, history or concurrency. Start with it, and bring in a profiler or monitoring service when the cost is not in the database or remote calls.

How do I find which plugin is slowest?

Open Queries by Component sorted by time, check the HTTP API requests and the Timeline, then deactivate the suspect on staging and compare the same URL as the same user. No single panel gives the verdict, so confirm the ranking by experiment before you remove or replace anything.

W
Written byWPresident EditorialThe WPresident editorial team. Every article says whether it comes from hands-on use or from documentation, and anything paid for is labelled.

Keep reading

Performance

How to Set Up Cloudflare for WordPress

A practical guide to putting Cloudflare in front of WordPress: nameservers, SSL modes, safe caching rules, WooCommerce bypasses, APO, security and a rollback plan.

Read more
WPresident Editorial
Performance

How to Fix High CPU Usage on WordPress

A practical diagnostic guide to WordPress CPU spikes: read host graphs and logs, tell traffic from code, then fix caching, bots, cron, Heartbeat and plugins.

Read more
WPresident Editorial

Get the Monthly Launch Report

One email a month: the best of last month's articles, new reviews and what changed in WordPress, without the noise.

No spam. Unsubscribe in one click.

Signed and sealed,
The WPresident
↑↓ move↵ openEsc closeAll results