Programming Tutorials

How to Use Query Monitor to Debug WordPress: A Practical Guide

When a WordPress page loads slowly, shows a warning, or behaves differently after a plugin or theme change, the difficult part is often finding which component caused the problem. Query Monitor is a developer-focused plugin that exposes diagnostic information for the current request, including database queries, PHP errors, hooks, scripts, stylesheets and server-side HTTP API calls.

This practical guide explains how to install Query Monitor, read its main panels and use the information to investigate a problem without guessing. It is useful for site owners who manage their own WordPress installation as well as developers working on themes and plugins. For safer testing, use a staging or local copy whenever you need to change code or deactivate components.

Advertisement

What is Query Monitor?

Query Monitor is an open-source WordPress developer tools plugin maintained by John Blackbourn. It adds a menu to the WordPress admin toolbar and provides panels with diagnostic information about the page or request being inspected.

It can help you investigate:

Advertisement
  • Database queries, including slow, duplicate or failed queries.
  • PHP errors, warnings, notices and deprecated-function messages.
  • The plugin, theme, core component or function associated with a query or error.
  • Scripts and stylesheets loaded on the page, including dependencies.
  • Server-side HTTP API requests and their response codes and timings.
  • Hooks and actions, template details, rewrite rules, REST API and Ajax request information.

Query Monitor is a diagnostic aid, not an automatic repair tool. It helps you narrow down where to investigate; you still need to understand the code or configuration before changing anything.

Before installing: check access and make a safe test plan

Use an account with the required administrative access. By default, Query Monitor displays its output to Administrators on a single-site installation and Super Admins on a Multisite installation. Some managed hosts apply additional capability rules, so follow the host’s documentation if the menu is missing.

Before testing a plugin or theme change, take a backup and use a staging or local environment if one is available. Avoid making experimental changes on a busy production site. You can read our WordPress backup and restore guide before making changes.

How to install Query Monitor

  1. Sign in to your WordPress dashboard with an administrator account.
  2. Open Plugins → Add New Plugin (the wording may vary slightly by WordPress version).
  3. Search for Query Monitor.
  4. Check that the plugin is the one maintained by John Blackbourn.
  5. Select Install Now, wait for installation to finish, and then select Activate.
  6. Open a page on your site while logged in. The Query Monitor menu should appear in the admin toolbar when the current user has permission to view its output.

Install it from the official WordPress.org plugin directory, and review the plugin page for current WordPress and PHP requirements before installation. Some hosting platforms may already bundle it.

Understanding the Query Monitor toolbar

The toolbar menu gives a quick overview of the request you are viewing. Depending on the page and what happened during its generation, it can show information such as page generation time, memory usage, database query counts, HTTP API calls and warnings.

Select a menu item to open the corresponding panel. The available details depend on the current request: for example, a PHP Errors panel may contain no entries when no PHP errors were recorded for that page. A clean panel is useful information, but it does not prove that every part of the website is error-free.

The most useful Query Monitor panels

1. Database Queries

The Database Queries panel lists queries executed during the current request. Query Monitor can flag slow, duplicate or erroneous queries and group query information by component or calling function. This helps you identify whether a theme, plugin or custom function is responsible for a query pattern.

When investigating a slow page:

  1. Open the affected page while logged in as an administrator.
  2. Open the Database Queries panel.
  3. Look for queries marked slow or associated with an error.
  4. Review the component and calling function shown for the query.
  5. Compare the result with another page that uses a different template or feature.
  6. Use the file and function details to decide what to inspect in the relevant plugin, theme or custom code.

Do not treat a high query count by itself as proof of a defect. The cost of a query, whether it is repeated, the page’s functionality and the time spent in the database all matter. A page with more queries can still be faster than a page with a smaller number of expensive queries.

2. PHP Errors

The PHP Errors panel displays errors, warnings, notices and deprecated-function messages generated during the request, where available. It can show the responsible component and a call stack that helps you trace the code path.

If an error points to a plugin file, record the exact message, file and line number. Check whether the problem occurs on every page or only when a particular feature is used. Then review the plugin’s documentation or support information and reproduce the issue on staging before changing or replacing the plugin.

3. Scripts and Styles

This panel shows the scripts and stylesheets enqueued for the page, along with their handles, URLs, versions and dependencies. It can help you find a script loaded on pages where it is not needed, a missing dependency, or a stylesheet associated with a visual problem.

Use the handle and source URL to identify which component registered the asset. Do not remove a script merely because its name is unfamiliar: a form, navigation menu, editor block or other feature may depend on it. Test any dequeue or optimisation change on staging and verify the feature afterwards.

4. HTTP API Calls

WordPress plugins and themes can make server-side HTTP requests to external services through the WordPress HTTP API. Query Monitor can show information about these requests, including response codes, the responsible component and the time taken.

If an integration is slow or failing, check the request’s response code, timeout and calling component. A failed request may be caused by the remote service, network restrictions, invalid credentials or plugin configuration. Query Monitor helps identify the request; it cannot determine the remote service’s internal cause on its own.

5. Hooks, Actions and Template

The Hooks & Actions panel shows hooks fired during the request and the callbacks attached to them. The template information helps you identify which template file and template hierarchy WordPress used to render the page. These panels are especially useful when debugging a custom theme or plugin that adds functionality through hooks.

6. REST API and Ajax requests

Query Monitor can expose diagnostic information for supported Ajax and authenticated REST API requests when the user has permission to view its output. This can help when a dashboard action, editor feature or plugin integration behaves differently from a normal page load. Inspect the browser’s developer tools alongside Query Monitor when the issue involves JavaScript or a request made by the browser.

A practical workflow for finding a slow WordPress page

Use the same URL and repeatable steps each time so that you are comparing similar requests.

  1. Reproduce the problem: note the page, user role, action and approximate time when the delay occurs.
  2. Open the page as an administrator: Query Monitor’s output is normally restricted to authorised users.
  3. Check the overview: note the request details, database query information, memory usage and warnings.
  4. Inspect the relevant panel: start with Database Queries for database-related delays, PHP Errors for warnings, or HTTP API Calls for slow integrations.
  5. Identify the component: use the plugin, theme, file or function information to narrow the investigation.
  6. Change one thing at a time: reproduce the issue on staging, test one change, and check that the affected feature still works.
  7. Retest the same page: compare the new request with the original and keep the change only if it resolves the problem without causing another issue.

For visitor-facing speed measurements, use a separate real-user or lab testing tool as well. Our WordPress Core Web Vitals guide explains how to test loading, responsiveness and layout stability. Query Monitor’s request-level diagnostics complement those measurements; they do not replace them.

Using WP_DEBUG with Query Monitor

Query Monitor can be useful without manually enabling WordPress debugging constants. If you also need WordPress’s built-in PHP logging, use it in a local or staging environment and follow the official WordPress guidance.

A common staging configuration is:

// Enable debugging in a local or staging environment.
define( 'WP_DEBUG', true );

// Write errors to wp-content/debug.log.
define( 'WP_DEBUG_LOG', true );

// Do not display errors in the page HTML.
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

Place the definitions in wp-config.php before the line that says /* That's all, stop editing! Happy blogging. */. Check first whether these constants are already defined; do not add duplicate definitions blindly.

Do not expose PHP errors to public visitors. WordPress recommends using WP_DEBUG in local or staging environments rather than on a live site. If you need a log, prefer a path outside the publicly accessible web root when your host supports it. The default wp-content/debug.log location may be reachable over the web if the server does not block access, so confirm that direct requests are denied. Remove or securely archive the log after testing, and disable debugging when it is no longer needed.

Security, privacy and performance considerations

  • Limit visibility: Query Monitor’s output is restricted to authorised administrators by default. Do not enable an authentication cookie for wider access unless you understand the implications.
  • Protect diagnostic data: query strings, file paths, request details and error messages may reveal information that should not be shared publicly. Redact sensitive details before sending diagnostic screenshots or logs to support.
  • Expect some overhead: Query Monitor adds a small amount of work to page generation. Its maintainer notes that memory use can become more noticeable on requests with hundreds of database queries.
  • Use it for diagnosis: once you have finished investigating, deactivate it if you no longer need it. Keep production changes controlled and follow your host’s policies.
  • Keep a recovery path: take a backup before changing plugin, theme or configuration files.

The plugin’s published privacy statement says that collected data is not persistently stored or sent to a third party by Query Monitor. That does not remove your responsibility to protect the diagnostic information displayed in your own dashboard.

Common problems and how to investigate them

Symptom Where to look Next step
Query Monitor menu is missing User permissions, plugin activation and host-specific rules Sign in with an authorised administrator account and check host documentation.
A page is slow Overview, Database Queries and HTTP API Calls Identify the slow component or external request; compare the same page after a controlled test.
A PHP warning appears PHP Errors Record the file, line and call stack, then reproduce on staging.
A script or style is missing Scripts & Styles Check handles and dependencies before changing enqueue logic.
An integration times out HTTP API Calls Check response details, timeout and the responsible plugin or theme.
The page looks different after a change Scripts & Styles, Hooks & Actions and Template Review the last change and test one component at a time.

Frequently asked questions

Is Query Monitor free?

Query Monitor is available from the WordPress.org plugin directory and its source code is published under the GPL-2.0 license. Review the official plugin page for the current distribution and requirements.

Can Query Monitor show which plugin is slowing down my site?

It can help identify queries, errors, scripts, styles or HTTP requests associated with a plugin or theme. That evidence can narrow the cause, but you should verify it with repeatable tests rather than assuming the component is responsible from one number alone.

Can visitors see Query Monitor?

By default, its output is shown to Administrators on single-site installations and Super Admins on Multisite installations. Do not broaden access unless you understand the security implications.

Does Query Monitor replace PageSpeed Insights?

No. Query Monitor helps inspect the WordPress request and the components involved. PageSpeed Insights and Core Web Vitals help assess loading, responsiveness and visual stability from a browser and real-user perspective. They answer different questions and can be used together.

Should I leave Query Monitor active permanently?

Use it when you need to diagnose a problem. Because it collects request-level information and adds some overhead, deactivate it when the investigation is finished unless your development workflow specifically requires it.

Compatibility and implementation notes

As of 1 December 2026, the official WordPress.org listing says Query Monitor requires PHP 7.4 or later, supports WordPress versions up to three years old, and is actively tested up to PHP 8.5. These details can change, so check the current plugin listing against your own WordPress and PHP versions before installing or updating it.

For detailed database-query attribution, Query Monitor uses a custom db.php drop-in linked into WP_CONTENT_DIR. If that directory is not writable and the drop-in cannot be installed, Query Monitor can still function, but its extended database-query instrumentation is unavailable. Do not create or replace the drop-in manually unless you understand the host’s file layout and have permission to do so.

The plugin’s maintainer describes its effect on page-generation time as small, but notes that memory use can become more noticeable on requests with hundreds of database queries. Treat its figures as diagnostic data from the request being inspected, not as a substitute for browser-based performance testing.

Optional: send a diagnostic message from custom code

If you maintain a theme or plugin, you can send a short message to Query Monitor’s Logs panel while investigating a specific code path:

do_action( 'qm/debug', 'Reached the custom import step' );

Place the message near the step you want to inspect, reproduce the request, and then look in the Logs panel. Remove temporary logging when the investigation is complete. Never include passwords, API tokens, payment details or personal information in diagnostic messages.

Conclusion

Query Monitor gives WordPress administrators and developers a practical way to inspect what happens during a page request. Start with the overview, then use the database, PHP error, script, HTTP API and template panels to narrow down the source of a problem. Record what you find, test changes in staging, and make one change at a time. Used carefully, it can turn vague reports such as “this page is slow” into a more focused investigation.

Official references

RochakGuy

Hi, I'm Piyush and I'm a passionate blogger. I love sharing my insights on Rochaksite.com. I'm committed to providing practical and informative content that helps readers achieve their goals and make informed decisions. When I'm not writing, I enjoy exploring new topics and trends in Technology and indulging in my personal hobbies and interests.

Related Articles

Back to top button