This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

📣 Join our live AMA on the Future of Page Builders with Brizy's CEO! Register Now →

How to Debug WordPress Performance Issues With Query Monitor

Updated on March 18, 2024

9 Min Read
WordPress Query Monitor Plugin

When working on a WordPress site with many plugins, performance issues may arise. Identifying them can be challenging. Developers typically resolve WordPress errors by excluding parts of the code that might be causing trouble or by turning off plugins one by one.

This process can be time-consuming. However, there’s a faster solution – the Query Monitor plugin. It offers a more efficient way to identify performance problems and understand your WordPress site’s workings.

In this guide, I’ll tell you everything about Query Monitor. It’s not just about identifying its purpose and functionality but also about how to use it effectively to debug your WordPress site’s issues and improve its performance.

Brief Overview of Query Monitor Plugin

Query Monitor Plugin

– Source: WordPress.org

Query Monitor stands out as a completely free plugin designed to assist you in troubleshooting performance and development issues on your WordPress site. It offers insights into database queries, scripts, timing, and more.

Once installed, Query Monitor adds a convenient entry to the top menu bar, offering a dropdown list that reveals the number of queries running on the current page.

This includes loading time, query types, components, and other details. This data empowers developers to better understand and address website errors.

It has been developed by John Blackbourn and is available on both the official WordPress Plugin Repository and on GitHub.

Query Monitor is regularly updated, and the development team provides prompt support and fixes for all reported bugs.

Master WordPress Performance Monitoring & Optimization [Free eBook]

Learn how to monitor your site’s performance and make necessary adjustments to optimize speed and security in our FREE eBook.

Thank You

Your Ebook Is on It’s Way to Your Inbox.

What Does Query Monitor Do?

Here’s what Query Monitor plugin can do for you:

  • Identify PHP errors.
  • Monitor memory usage.
  • Analyze database queries, including those from specific plugins.
  • Track HTTP API calls on your WordPress site.
  • Explore enqueued scripts and styles, along with their dependencies.
  • Understand hooks and actions influencing your site’s behavior.
  • Examine theme template files in use.
  • Check languages and translations within your site.
  • Review rewrite rules affecting your site’s URLs.
  • Analyze the blocks present in the WordPress block editor.
  • Access general environment information about your site.
  • Gain insights into the performance of WordPress admin screens.

The plugin’s installation is quite simple and generally does not require any additional steps (compared to the installation process of similar plugins), nor does it require any additional configuration after installation.

It displays the dropdown list in the admin toolbar right out of the box.

What Does Query Monitor Do

You can access the details of the queries made to the database, CSS, active hooks, and the HTTP API calls by clicking the entries in the dropdown list.

Access query details, CSS, active hooks, and HTTP API calls by clicking on dropdown list entries.

New Relic can also help you monitor the performance of your WordPress site even more conveniently, right from the Cloudways dashboard. But we’ll get to that a bit later in the blog.

System Requirements of Query Monitor

To use Query Monitor, your system should have WordPress (versions up to three years old are supported) and PHP version 7.4 or higher. For more details, you can visit the Query Monitor website.

Optimize Your WordPress Experience With Cloudways!

Leverage seamless plugin integration, automated updates, and a user-friendly platform tailored to enhance your WordPress performance and monitoring with ease.

Why Is Query Monitor Useful for Developers?

The Query Monitor plugin helps developers identify areas for improvement, revealing plugins or assets causing resource issues or conflicts.

It efficiently addresses bottlenecks, allowing for code enhancements or replacing problematic elements. This benefits website owners and developers aiming to optimize performance.

To help you better understand the benefit of using Query Monitor, let’s consider a simple dev task that would typically require leveraging code—finding out the page load time and the number of active queries on the page.

WordPress offers two simple functions: get_num_queries() and timer_stop(). These codes can help you identify performance bottlenecks, requiring a certain level of technical knowledge to interpret effectively.

Query Monitor automates the process of adding functions to your code and checking the results, saving you from doing it manually. It displays the number of database queries and provides insights into various aspects of your site’s performance and functionality.

Features of WordPress Query Monitor

Here is a comprehensive overview of the Query Monitor’s remarkable features:

1. Database Queries

  • Notifications for slow, duplicate, or erroneous queries.
  • Filtering options by query type, responsible component (plugin, theme, WordPress core), and calling function.
  • Aggregate views for each query type, providing a detailed breakdown.

2. Template Information

Display of template filename, complete template hierarchy, and loaded or unloaded template parts (for block themes and classic themes).

3. PHP Errors

  • Presentation of PHP errors with details on the responsible component, call stack, and a visible warning in the admin toolbar.
  • Identify deprecated or “Doing it Wrong” functionality usage in the code.

4. Blocks and Full Site Editing (FSE)

Insight into blocks and associated properties within post content and FSE.

5. Rewrite Rules and Query Strings

Display of matched rewrite rules, associated query strings, and query vars.

6. Enqueued Scripts and Stylesheets

Information on enqueued scripts and stylesheets, including dependencies and alerts for broken dependencies.

7. Language Settings

Details on language settings and loaded translation files (MO files and JSON files) for each text-domain.

8. HTTP API Requests

Record of HTTP API requests with response code, responsible component, and time taken, along with alerts for failed or erroneous requests.

9. User Capability Checks

Reporting of user capability checks, including the result and parameters passed to the capability check.

10. Environment Information

Detailed information about PHP, the database, WordPress, and the web server.

11. Conditional Functions

Values of all WordPress conditional functions, such as is_single(), is_home(), etc.

12. Transients and Multisite Functionality

Identification of updated transients and usage of switch_to_blog() and restore_current_blog() on Multisite installations.

13. Redirects

Automatic addition of an HTTP header containing the call stack whenever a redirect occurs.

14. AJAX Calls

Dynamic WordPress sites make many Ajax calls for sending and fetching data in real time without loading the complete web page. Query Monitor also shows these requests along with other useful debugging information. This information helps the developer in highlighting any errors.

15. REST API

If you have permission to monitor the Query Monitor, you can debug the information in the header of an authenticated WordPress REST API request.

16. Authentication

By default, only the admin of a single-site installation and the super admin of a WordPress Multisite can view the logs inside the Query Monitor. However, you can configure an authentication cookie to see the logs even when logged in as a user.

17. Privacy Statement

WordPress Query Monitor operates with a commitment to user privacy. It does not collect nor transmit any data to third parties. Your information remains secure and confidential when utilizing this tool.

How to Use WordPress Query Monitor?

Once you have installed and activated Query Monitor from the WordPress Dashboard, you need to follow the steps below:

  • Go to Plugins;
  • Click Installed Plugins Query Monitor;
  • Click Settings;
  • Click on the “Set authentication cookie” button.

Now, let’s see each section of the Query Monitor plugin in detail.

Overview

The first tab provides you with an overview of your website. It shows you page generation time, peak memory usage, database query time, and database queries.

Website overview with page generation time, peak memory usage, database query time, and queries displayed

Database Queries

A database query is triggered whenever a user requests or tries to submit any information.

Query Monitor tracks this query and displays it inside the logs so that you, as a user, can see which queries were executed successfully and which were not. It also lets you filter by the type and component of the query.

Query Monitor tracks and logs queries, enabling users to easily identify successful and unsuccessful query executions.

Object Cache

The Overview panel in Query Monitor provides information about your site, including the object cache. Query Monitor will display a message if you lack a persistent object caching plugin.

A persistent object cache plugin enhances performance by caching results from operations like database queries.

If you see “External object cache not in use,” install a caching plugin like Redis or Memcached for persistent caching. This significantly boosts your site’s performance. Consult your hosting provider for assistance.

Overview panel in Query Monitor Site details, including object cache status. Message displayed for missing persistent object caching plugin

Timings

The Timings panel in Query Monitor records and displays the time taken and approximate memory usage during the qm/start and qm/stop actions for the specified function name.

It’s important to note that the displayed times and memory usage in the Timings panel are approximate and should be treated as such.

The Timings panel in Query Monitor

Logs

The Log tab in Query Monitor is an advanced feature that allows you to log messages and variables, aiding in troubleshooting technical issues or monitoring your site for potential problems.

Upon the initial installation of Query Monitor, the tab will be empty as no logging variables have been configured.

The Log tab in Query Monitor

Request

The Request feature shows the query variable for the current user and highlights the custom query. It also shows the associated query strings present inside a request.

The Request feature shows the query variable for the current user and highlights the custom query

Admin Screen

The admin screen section shows the activities happening on the WordPress admin panel. It lists down the components accessed from the admin panel and shows an error due to the unavailability of any PHP file.

The admin screen section shows the activities happening on the WordPress admin panel

Scripts

When you visit the Scripts tab inside the Query Monitor, it lists all the queued scripts and styles enclosed within the request. It also highlights any broken or unresponsive script due to an external dependency.

Scripts tab inside the Query Monitor

Styles

The Styles tab in Query Monitor functions similarly to the Scripts tab, but instead of showcasing JavaScript, it focuses on enqueued CSS. This tab is valuable for debugging site performance.

Loading multiple stylesheets, like scripts, contributes to slower site loading times. Utilizing this tab can optimize your website by reducing the number of stylesheets, leading to smaller files and fewer HTTP requests.

The Styles tab in Query Monitor

Hooks and Actions

Hooks and actions are essential in any WordPress site as they allow you to create a custom functionality using the predefined controls provided by WordPress. However, doing so can sometimes break your website, and troubleshooting the error could be tiring.

Thanks to Query Monitor, which has a built-in tool to identify errors caused by hooks and actions, you can filter actions and hooks by core, theme, or plugin. It also gives you the complete name and reference, easily found inside the code for debugging purposes.

Hooks and actions

Languages

In the case of a multilingual website, the Language tab identifies any broken or unavailable files and displays the language settings.

Language tab

HTTP API Calls

This tab shows all the server-side queries and the response code, timeout log, and failed requests. It is a useful feature as it lets you see the response in real-time and helps you debug the server-side code efficiently.

HTTP API Calls shows all the server side queries and the response code, timeout log, and failed requests

Transient Updates

WordPress can cache the API response in its database, as some APIs allow a certain number of requests at a given time. Transient Updates shows these transients and also displays the size and the component.

Transient Updates

Capability Checks

By default, this is inactive and can be activated by placing the code inside the wp-config.php file. Capability Checks performs capability checks for each user on the page and displays the parameters and results.

Capability Checks

Environment

This is a complete WordPress environment overview containing the PHP, Database, and WordPress sections. Each section displays the environment’s helpful information, such as MySQL version, PHP memory limit, WordPress version, etc.

Environment

Conditionals

The Conditionals feature in Query Monitor displays all the WordPress conditionals relevant to the current request, indicating whether each conditional evaluates to “True” or “False.” This provides insight into the conditional logic applied during the page load.

Conditionals

Summary

WordPress Query Monitor plugin is a powerful plugin for debugging, offering detailed information in an easily understandable format. It proves especially beneficial for swiftly identifying the impact of plugins, themes, or functions on a website’s performance.

The fact that the Query Monitor plugin seamlessly integrates a menu into the admin toolbar, providing a quick snapshot of the current page and delivering comprehensive data in a panel upon menu item selection, is a noteworthy feature.

Which of these components do you often use to keep your site healthy? Try this plugin out and let us know in the comment section below.

Q1. Where is Query Monitor located in WordPress?

A. Query Monitor is accessible through the WordPress admin bar. Clicking on the summary opens the full Query Monitor interface, displayed as a window overlay on the current front or backend page.

Q2. How do I optimize a WordPress query?

A. Optimizing your WordPress database involves table optimization through SQL commands, cleaning up unwanted data, deleting post revisions, removing spam comments, deleting unused tags, eliminating pingbacks and trackbacks, and uninstalling unused plugins and themes.

Q3. Where are WordPress error logs located?

A. To access error logs in WordPress, go to your /wp-content/ folder using the File Manager. Look for the debug.log file within this folder, which contains a comprehensive record of all logged WordPress errors, warnings, and notices.

Share your opinion in the comment section. COMMENT NOW

Share This Article

Mansoor Ahmed Khan

Been in content marketing since 2014, and I still get a kick out of creating stories that resonate with the target audience and drive results. At Cloudways by DigitalOcean (a leading cloud hosting company, btw!), I lead a dream team of content creators. Together, we brainstorm, write, and churn out awesome content across all the channels: blogs, social media, emails, you name it! You can reach out to me at [email protected].

×

Get Our Newsletter
Be the first to get the latest updates and tutorials.

Thankyou for Subscribing Us!

×

Webinar: How to Get 100% Scores on Core Web Vitals

Join Joe Williams & Aleksandar Savkovic on 29th of March, 2021.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Want to Experience the Cloudways Platform in Its Full Glory?

Take a FREE guided tour of Cloudways and see for yourself how easily you can manage your server & apps on the leading cloud-hosting platform.

Start my tour

CYBER WEEK SAVINGS

  • 0

    Days

  • 0

    Hours

  • 0

    Mints

  • 0

    Sec

GET OFFER

For 4 Months &
40 Free Migrations

For 4 Months &
40 Free Migrations

Upgrade Now