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.

WordPress Query Monitor Plugin: Let’s Debug and Improve Performance

Updated on January 10, 2022

7 Min Read
wordpress query monitor

Are you getting WordPress errors but don’t know how to resolve them?

WordPress developers usually work in reverse to detect WordPress errors. They start by excluding code sections that might harbor the issue(s) and then evaluate individual areas. Generally, the major areas of concern are PHP settings, .htaccess file, wp-config file, database queries, and DNS settings.

Recently, I came across the WordPress Query Monitor plugin, a great dev tool for discovering the happenings on the website. The plugin offers detailed information to help developers narrow down the “troubled” areas of the code.

In this plugin’s tutorial, I will begin with a detailed introduction of the WordPress Query Monitor plugin and a brief description of the plugin’s use case.

What Is WordPress Query Monitor?

Query Monitor is a WordPress plugin that adds significant value to the debugging phase and generally improves the overall performance of your WordPress dev workflows.

The plugin adds an entry in the top menu bar that acts as a dropdown list that contains the number of queries being executed on the current page. It includes the loading time, filters by type of query, components, etc. As a result, developers have a better idea of the reasons behind the errors on a website.

wordpress query monitor plugin

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.

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. Right out of the box, it starts displaying the dropdown list in the admin toolbar.

query monitor settings

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.

query montior toolbar

Features of WordPress Query Monitor

Here is a quick overview of the Query Monitor’s most striking features.

Theme Errors

Theme feature lists down all the queries triggered by the installed WordPress theme. It displays the file name of the theme template responsible for a specific query and shows the complete template hierarchy. The theme feature also highlights the unloaded theme parts and the name of the active WordPress theme.

PHP Errors

WordPress runs on PHP, and whether a theme or a plugin generates the request, it is in the form of a PHP code. PHP Errors feature highlights the source components and the location responsible for generating the query.

Note: Not all the queries listed inside the Query Monitor are serious. It may be just a warning.

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.

REST API

If you have permission to monitor the Query Monitor, you can debug the information presented inside the header of an authenticated WordPress REST API request. Currently, the plugin only supports PHP errors and memory usage.

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.

Privacy Statement

WordPress Query Monitor neither collects nor sends any data to third parties.

I have also noticed that the Debug Bar add-ons can be used with Query Monitor; however, you’d need to deactivate the Debug Bar first. Also, there are add-ons for the Query Monitor for a better user experience.

Why Is Query Monitor Useful for Developers?

Developers get a fair idea of the improvement areas thanks to the Query Monitor plugin. Moreover, they can discover the plugin or other website assets that are consuming an abnormal volume of resources or (in worse cases) are conflicting with the rest of the core files.

Query Monitor is an ideal solution for identifying bottlenecks that can be rectified with improved code snippets, alternatives, or in some cases, complete replacement of scripts/plugins. Hence, it is beneficial for the website owners and developers interested in improving Web Performance Optimization (WPO).

Let’s consider a simple dev task – 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(). As the name explains, the get_num_queries () returns the number of database queries generated during the execution, and timer_stop() returns the number of seconds required to generate the page.

How to Use WordPress Query Monitor [Easy Steps]

Once you have installed and activated Query Monitor, 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.

query monitor overview

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.

database queries

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.

request feature

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.

admin screen

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

Styles

It is possible that at times due to an external dependency, a certain CSS file does not load and breaks the layout of your web page. This section deals with the CSS Style sheets and helps you identify the source files behind any query.

styles

Hooks and Actions

Hooks and actions play an essential part in any WordPress site as they allow you to create a custom functionality using the predefined controls provided by WordPress. 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, allowing you to 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.

languages

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 enables you to see the response in real-time and helps you to debug the server-side code efficiently.

http api calls

Transient Updates

WordPress is capable of caching 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 along with the result.

capability checks

Environment

This is a complete overview of the WordPress environment and contains 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 shows all the WordPress conditionals on the current request.

conditionals

Wrapping Up!

WordPress Query Monitor plugin focuses on debugging and provides all pertinent information in an easy-to-understand way. The plugin is ideal for quickly identifying the plugins, themes, or functions affecting the website’s performance.

The plugin integrates a menu in the admin toolbar that shows a general description of the current page, with complete data displayed in a panel (once you select a menu item). Which of these components do you often use to keep your site healthy? Enlighten us in the comment section below.

Share your opinion in the comment section. COMMENT NOW

Share This Article

Customer Review at

“Beautifully optimized hosting for WordPress and Magento”

Arda Burak [Agency Owner]

Mansoor Ahmed Khan

Passionate about technology, entrepreneurship, and marketing, Mansoor Ahmed Khan is in computing since he knows how to type on a keyboard. His daily life is rocked by his family, projects, and his screen. Probably in this order, he likes to be convinced at least. You can reach out to him 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!