How to Debug WordPress Performance Issues With Query Monitor plugin

Is your WordPress site slowed down? Need a faster solution to identify and fix performance issues?

The Query Monitor plugin efficiently pinpoints performance issues and helps you better understand your WordPress site’s functionality.

Overview of Query Monitor

Query Monitor is a free plugin specially created to help you solve performance and development problems on your WordPress site. It provides information about database queries, scripts, timing, and more.

It covers information like how long it takes to load, the types of queries, different components, and other details. This data helps developers better understand website errors and how to fix them.

John Blackbourn has developed it and is available on the official WordPress Plugin Repository and GitHub.

Query Monitor receives regular updates, and the development team offers quick support and solutions for any reported issues.

Features of Query Monitor

1. Database Queries

  • Receive alerts for queries that need to be faster, duplicated, or problematic.
  • Your results can be filtered based on the type of Query, the responsible component (such as a plugin, theme, or WordPress core), or the calling function.
  • Get an overview of each query type with detailed breakdowns in aggregate views.

2. Template Information

You can see the name of the template file, the entire template hierarchy, and which template parts are loaded or unloaded (especially for block and classic themes).

3. PHP Error Reporting

  • View PHP errors along with information about the component causing the issue, the call stack, and a visible warning in the admin toolbar.
  • Identify the usage of deprecated or incorrect functionality in the code.

4. Blocks and Full Site Editing (FSE)

Look closely at blocks and their properties within post content and Full Site Editing (FSE).

5. Rewrite Rules and Query Parameters

See the matched rewrite rules, connected query strings, and query variables in a clear display.

6. Enqueued Scripts and Stylesheets

Find details about the scripts and stylesheets loaded, along with their dependencies. Get alerts for any broken dependencies.

7. Language Settings

Get information about your language settings and the translation files (MO and JSON files) loaded for each text-domain.

8. HTTP API Requests

Keep track of HTTP API requests with the response code, the responsible component, and the time taken. Receive notifications for any failed or erroneous requests.

9. User Capability Checks

Receive reports on user capability checks, showing the result and the parameters passed to each capability check.

10. Environment information

Get comprehensive information about PHP, the database, WordPress, and the web server in one place.

11. Conditional functions

To understand the current context or state, you can see the outcomes of various WordPress conditional functions, like is_single(), is_home(), and others.

12. Transient Data and Multisite Operations

Spot updated transient data and recognize the usage of switch_to_blog() and restore_current_blog() in Multisite installations.

13. Redirects

Automatically include an HTTP header that shows the call stack whenever a redirect happens, providing insights into the redirection process.

14. AJAX calls

In dynamic WordPress websites, Ajax calls are made to send and retrieve data in real time, avoiding reloading the entire webpage. Query Monitor displays these requests, along with additional helpful debugging details. This information helps developers identify and address errors.

15. REST API

If you have the necessary permissions to monitor Query Monitor, you can troubleshoot information found in the header of an authenticated WordPress REST API request.

16. Authentication

Usually, only the site administrator or a WordPress Multisite super admin can see Query Monitor logs. However, you can create cookie authentication to access the logs regularly.

17. Privacy Statement

WordPress Query Monitor is designed with a solid commitment to user privacy. It does not gather or send any data to third parties, ensuring the safety and confidentiality of your information.

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.

To better understand Query Monitor’s benefits, consider a typical development task – determining page load time and the number of active queries.

WordPress provides two functions,get_num_queries()andtimer_stop(), which require technical knowledge to interpret.

Query Monitor automates this process, adding functions to your code and displaying the results, saving you from manual intervention. It showcases the number of database queries and offers insights into your site’s performance and functionality.

System requirement of Query Monitor

  • WordPress (compatible with versions up to three years old)
  • PHP version 7.4 or later.

For additional information, please visit the Query Monitor website.

How to Install Query Monitor?

  1. Log in to your WordPress dashboard.
  2. Scroll down to the “Plugins” section on the left-hand menu.
  3. Click on “Add New Plugins.”
  4. In the search bar on the top right, type “Query Monitor.”
  5. Once the Query Monitor plugin appears in the search results, click “Install Now.”

After installation, click “Activate” to activate the plugin.
Now, it displays on the list in the plugins section without any additional setup.

Clicking on the entries in the dropdown list allows you to view details of database queries, CSS, active hooks, and HTTP API calls.

How To Use WordPress Query Monitor?

After successfully installing and activating Query Monitor from the WordPress Dashboard, proceed with the following steps:

  1. Log in to your WordPress dashboard.
  2. Navigate to the Plugins section.
  3. Select Installed Plugins and then find and click on Query Monitor.
  4. Now click the Settings option.

  1. Click the Set authentication cookie button.

Let’s explore each section of the Query Monitor plugin in detail.

  • Overview

    The initial tab4 summarizes your website, displaying page generation time, peak memory usage, database query time, and the number of database queries.

  • Database Queries

    When a user asks for or submits information, it triggers a database query.

    This feature allows users to observe both successful and unsuccessful query executions. Additionally, users can filter queries based on their type and associated components.

  • Object cache

    The Overview panel in Query Monitor offers insights into various aspects of your site, including the object cache. If you don’t have a persistent object caching plugin, Query Monitor will show a message indicating this.

    A persistent object cache plugin boosts performance by storing results from operations such as database queries for quick retrieval.

    If the “External object cache not in use” message appears, consider installing a persistent caching plugin like Redis or Memcached. This can significantly enhance your site’s performance.

  • Timings

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

    It’s crucial to acknowledge that the times and memory usage shown in the Timings panel are approximate and should be regarded as such.

  • Logs

    The Log tab in Query Monitor is a sophisticated feature enabling you to record messages and variables. This proves invaluable for troubleshooting technical issues or monitoring your site for potential problems.

    After installing Query Monitor for the first time, the tab will be empty since no logging variables have been set up yet.

  • Request

    The Request feature displays the query variable for the current user and shows the custom query. It also reveals any associated query strings within a request.

  • Admin Screen

    The admin screen section shows the activities occurring on the WordPress admin panel. It provides a list of components accessed from the admin panel and highlights errors caused by the absence of any PHP file.

  • Scripts

    When you go to the Scripts tab in Query Monitor, it displays all the queued scripts and styles associated with the request. It also highlights any broken or unresponsive scripts caused by external dependencies.

  • Styles

    The Styles tab in Query Monitor operates similarly to the Scripts tab, but instead of highlighting JavaScript, it concentrates on enqueued CSS. This tab helps debug and optimize site performance.

    Loading numerous stylesheets, like scripts, can slow down your site’s loading times. This tab allows you to optimize your website by minimizing the number of stylesheets, resulting in smaller files and fewer HTTP requests.

  • Hooks and Action

    Query Monitor comes to the rescue with its built-in tool to identify errors from hooks and actions. With this tool, you can filter actions and hooks based on core, theme, or plugin. Additionally, it provides the complete name and reference, making it easily locatable within the code for effective debugging.

  • Languages

    The Language tab detects broken or unavailable files for a multilingual website and displays the language settings.

  • HTTP API calls

    This tab displays all the server-side queries, including the response code, timeout log, and failed requests. It proves valuable as it allows you to observe real-time responses and facilitates efficient debugging of server-side code.

  • Transient Updates

    WordPress can store the API response in its database, particularly when certain APIs permit a specific number of requests within a given timeframe.

    The Transient Updates section in Query Monitor reveals these transients and provides information on their size and associated components.

  • Capability Checks

    This feature is deactivated by default but can be activated by inserting the code into the wp-config.php file. It conducts capability checks for each user on the page and exhibits the parameters and results.

  • Environment

    This provides a comprehensive overview of the WordPress environment, encompassing the PHP, Database, and WordPress sections. Each section presents valuable information about the environment, including the MySQL version, PHP memory limit, WordPress version, and more.

  • Conditional

    The Conditionals feature in Query Monitor displays all the WordPress conditionals relevant to the ongoing request, signaling whether each conditional is assessed as “True” or “False.”

    This grants a deeper understanding of the conditional logic implemented during the page load.

Other Tools to Debug and Improve Your Site Speed

  1. Google PageSpeed Isights

    PageSpeed Insights (PSI) by Google is a widely used, complementary tool for analyzing a website’s speed on mobile and desktop platforms.

  2. GTmetrix

    GTmetrix is an online tool for assessing website speed. It analyses a site’s load time, size, and requests, providing a score and recommendations for enhancement.

Does Query Monitor slow down my website?

  • Page Load Time:

    Query Monitor may cause a slight delay in page generation, usually between 10 and 100 milliseconds. However, this delay is generally acceptable for most websites and is similar to other plugins’ overhead.

  • Memory Usage:

    Query Monitor typically contributes around 10% of the total memory consumed during page generation. This percentage is relatively low and shouldn’t cause significant memory issues on most web server configurations.

However, if your website experiences performance bottlenecks or you’re managing a high-traffic site, even minor performance impacts can become noticeable. In such cases, consider:

  • Disabling Query Monitor temporarily:

    When you’re not actively debugging, temporarily disabling Query Monitor can offer a slight performance boost. Remember to re-enable it when needed for further analysis.

  • Optimizing other aspects:

    Focus on optimizing other areas, such as server configuration, theme and plugin choices, and image optimization, as these can have a more significant impact on website performance.

Can you stop Query Monitor from tracking long processes?

Yes. Query Monitor allows you to exclude long-running processes from its data collection selectively.

  • Backups and restorations:

    Pausing Query Monitor during backups eliminates unnecessary overhead and improves backup performance.

  • Data exports:

    Disabling Query Monitor can be beneficial when dealing with significant data exports. This can help to free up resources and prevent any potential data skewing caused by the extra monitoring activity.

  • Security scans:

    Stopping data collection during scans allows the scan to run efficiently and avoids unnecessary data accumulation.

Conclusion

The WordPress Query Monitor plugin is a robust tool for debugging, offering detailed information in a user-friendly format. It is particularly advantageous for quickly pinpointing the impact of plugins, themes, or functions on a website’s performance.

One notable feature of the Query Monitor plugin is its seamless integration of a menu into the admin toolbar. This menu offers a rapid overview of the current page, and upon selecting the menu item, it presents comprehensive data in a panel.

Frequently Asked Questions

Q1. Is Query Monitor suitable for beginners or designed primarily for experienced developers?

Query Monitor proves valuable for users of all experience levels. Beginners can utilize it to gain insights into their site’s performance, while experienced developers can use its advanced debugging capabilities.

Q2. Can Query Monitor be used to troubleshoot server-side issues in WordPress?

Absolutely. Query Monitor is a valuable tool for troubleshooting server-side issues in WordPress. It showcases server-side queries, response codes, timeout logs, and real-time failed requests, providing insights for effectively debugging server-side code.

Q3. Who can access/ see Query’s monitor’s output?

By default, Query Monitor prioritizes data security and limits access to its output based on user roles:

  1. Single-site installations: Only Administrators can access Query Monitor data.
  2. Multisite installations: Only Super Admins have access by default.

Experience the next level of speed with our WordPress hosting!

Turbocharge your website and give visitors a lightning-fast online experience.

(Visited 1,198 times, 3 visits today)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.