🎉 AgentWP is now in Public Beta Testing.
Struggling with a slow WordPress backend?
Query Monitor is a powerful plugin that helps you diagnose issues that might be slowing your website. In this guide, we’ll show you how to use this plugin effectively to pinpoint the culprits, understand their impact on your site's speed, and take steps to address these issues.
By the end, you'll know how to optimize your site, whether you're a seasoned developer or a WordPress novice
Why Your WordPress Backend Is So Slow
A sluggish WordPress backend can turn your simple tasks into frustrating ordeals.
Picture this. You’re trying to update a blog post, but your cursor is lagging with every keystroke. Or you're trying to adjust a plugin setting, only to be left staring at a never-ending loading screen.
All of these can seriously hamper your productivity and deter you from maintaining your site effectively.
There are many possible reasons why your WordPress admin is slow. We’ve listed below some of the possible culprits:
- Outdated WordPress core, theme, or plugins
- Poorly coded or resource-intensive plugins that cause inefficient database queries and consume excessive memory
- High server load due to shared hosting or insufficient resources
- Inefficient themes that load many scripts, stylesheets, or large media files
- Low PHP memory limit
- Running an old PHP version that lacks performance optimizations
- Too many external HTTP requests
- Database bloat caused by spam comments, post revisions, and expired transients
- Background tasks like security scans or automated backups that consume server resources
Identifying these issues is the first step to speeding up your WordPress backend. Now, let's explore how Query Monitor can help you diagnose and fix these issues!
Why Use Query Monitor?
Query Monitor is a powerful WordPress plugin commonly used by developers to identify and fix performance issues on their sites.
When you install and activate Query Monitor, you’ll find its insights available directly in your WordPress admin toolbar. This convenient access means you can quickly review important metrics and data without navigating away from your current tasks.
Here’s a closer look at some of the key features of Query Monitor:
- Provides a detailed overview of the current page via the admin toolbar.
- Displays all the database queries executed during a page load and highlights those that are particularly slow or inefficient.
- Keeps track of PHP errors so you can easily spot and resolve any issues.
- Shows which hooks and actions are fired during a request so that developers can understand the sequence of events that occur in WordPress.
- For sites using the Gutenberg block editor, Query Monitor provides information about the blocks used on a page.
- Lists all the scripts and stylesheets that are enqueued for a page so that you can identify any that might be causing conflicts or loading unnecessarily.
- Tracks outbound HTTP requests made by your site, which can be useful for diagnosing issues with external APIs or third-party services.
- Supports debugging of Ajax and REST API calls, user capability checks, and full site editing.
For WordPress developers, Query Monitor is incredibly useful because it reveals hidden performance issues. Instead of manually adding code to check page load times or query counts, developers can access this information instantly through the plugin’s interface.
For example, if you're trying to find out the page load time and the number of active queries on a page, you would typically use get_num_queries() and timer_stop(). But with Query Monitor, you no longer need to add code snippets. The plugin automatically shows the number of database queries and provides insights into your site's performance and functionality.
Overall, Query Monitor is a powerful tool, but it has limitations. It only shows data for the current page load, not historical information. This makes it hard to catch rare issues. The most common workaround for this is to pair it with Log HTTP Requests so you can get a more complete picture of what's happening behind the scenes.
Before You Begin
1) Use the Latest WordPress and PHP Version
To get the most out of Query Monitor, ensure your WordPress environment meets these requirements:
- WordPress version should not be older than three years
- PHP version should be 7.4 or higher
To check your PHP version, log in to your hosting account’s cPanel and look in the software section. It's important to keep your PHP version up to date to avoid compatibility issues and security risks.
2) Install Query Monitor
Simply go to "Plugins" > "Add New" in your WordPress dashboard. Search for "Query Monitor," click "Install Now," and then "Activate."
Once activated, Query Monitor adds a new item to your admin toolbar where you can access its features and view debugging info directly.
3) Disable All Caching
Caching can hide real-time changes and issues. So before using Query Monitor, make sure to turn off all caching on your site to get accurate data. This includes:
- Server-side caching: Disable any caching solutions provided by your hosting service.
- Plugin-based caching: Turn off caching plugins such as WP Super Cache, W3 Total Cache, or any similar tools.
- Browser caching: Clear your browser cache to ensure you’re viewing the most recent version of your site.
By doing this, Query Monitor will work properly and give you accurate insights into your site's performance. You can safely re-enable these settings once you’re done testing.
Query Monitor Interface - Overview
After activating Query Monitor, you'll notice some new metrics in your WordPress admin bar. These numbers display the health status of your site at a glance.
Here’s what you’ll see:
- Page Generation Time: This tells you how long it takes to create the entire web page. It's a crucial indicator of your site's speed and, by extension, user experience.
- Peak Memory Usage: This shows the maximum memory your page consumes while loading. It's particularly important if you're on shared hosting with limited resources.
- Database Query Time: This reveals how long your database queries are taking. In our experience, optimizing this can significantly boost your site's performance.
- Number of Database Queries: This count can be eye-opening. We've seen sites with hundreds of queries per page load, which often indicates room for optimization.
Now, clicking on any of these metrics in the admin bar opens a navigation dropdown.
For a deep dive, check out the Query Monitor panel at the bottom of the page. It breaks down information into categories like Queries, PHP Errors, and HTTP API Calls. Keep an eye out for sections in red, brown, or orange - these are areas that might need your attention.
You can also customize Query Monitor's behavior through the settings gear icon. This includes options to set an authentication cookie for non-admin users, configure code editor preferences, and adjust color schemes.
Note: For those who like to tinker under the hood, there are configuration constants you can add to wp-config.php for more advanced control, such as hiding WordPress core actions or disabling Query Monitor entirely.
How to Use Query Monitor
Now that you’ve got Query Monitor up and running, let’s dive into how we can use it to diagnose performance issues on your WordPress site.
Overview
First stop is the Overview panel. In a nutshell, this is your site’s health dashboard.
The Overview tab displays key metrics like page generation time, memory usage, and database query details. It's also where you'll find out if you're using object caching. If you see "External object cache not in use," consider adding a caching plugin like Redis or Memcached. It's a simple way to give your site a speed boost.
Database Queries
Next up is the Database Queries tab. This is where notifications for slow, duplicate, or erroneous queries are displayed. From here, you can filter queries by type, component (plugin, theme, WordPress core), or calling function.
Timings
The Timings panel displays how long and how much memory is used between qm/start and qm/stop actions. It's not exact, but it's a great starting point for optimization.
Logs
The Logs panel logs messages and variables which are incredibly useful for tracking down elusive issues. Initially, it will provide you with a clean slate for custom logging until these variables are configured.
Request
The Request tab in Query Monitor details the current HTTP request to your WordPress site. This includes the request URL, HTTP method (GET), and various request headers like Accept-Encoding and User-Agent. It also lists hooks with filters or actions that are useful for debugging and understanding your site's operation.
Admin Screen
The Admin Screen panel shows you what's happening in the backend. It tracks user actions and detects errors like missing PHP files. You'll see details about the current admin screen, including its base, ID, and parent file.
Scripts
When you access the Scripts tab in Query Monitor, it lists all the enqueued scripts within the request. It also helps you identify any broken or unresponsive scripts caused by external dependencies.
Styles
The Styles tab functions similarly to the Scripts tab but focuses on enqueued CSS files. It helps optimize your site by reducing the number of stylesheets, resulting in smaller file sizes and fewer HTTP requests.
Hooks & Actions
Hooks and actions are key for customizing your WordPress site, but they can cause issues if not implemented correctly. With Query Monitor’s built-in tools, you can easily identify errors caused by hooks and actions. You can filter by core, theme, or plugin, and access detailed names and references to easily locate and debug issues in your code.
Languages
The Languages panel helps you identify any broken or unavailable files on a multilingual website. It also ensures all language files are intact and properly configured.
HTTP API Calls
The HTTP API Calls panel shows details about server-side HTTP requests made while your page loads. When plugins or themes make frequent API calls during page loads, it can noticeably slow down your site. With Query Monitor, you can easily identify and manage these calls.
Transient Updates
The Transient Updates tab provides details such as the transient key, expiration time (if specified), size, updating function or method, and associated components. Transients are like quick caches that help speed up your site by cutting down on how often it talks to the database. This tab helps you keep an eye on and tweak how these caches work in WordPress to make things run smoother.
Capability Checks
The Capability Checks tab checks what each user can do on your site. It shows exactly what permissions are tested and what each user can access. You can activate this by adding define( 'QM_ENABLE_CAPS_PANEL', true ); to wp-config.php,
Environment
The Environment panel gives you an overview of your WordPress setup, including PHP, Database, and WordPress info. It shows key details like MySQL version, PHP memory limit, and WordPress version, so you can better understand and manage your site's technical setup.
Conditionals
The Conditionals tab lists WordPress conditionals checked during page requests, grouped into true and false categories.
True conditionals like is_admin(), is_blog_admin(), and is_ssl() verify aspects such as admin area presence, dashboard inclusion, and HTTPS usage. False conditionals, such as is_404(), is_archive(), and is_single(), identify error pages, archive views, and single post displays.
How to Troubleshoot a Slow WordPress Backend Using Query Monitor
Poorly optimized plugins are a frequent culprit behind sluggish WordPress backends. These plugins often run inefficient database queries, use excessive memory, or carry out complex operations that strain your system.
Since many plugins operate within the WordPress admin area, those that aren't well-optimized can hog resources. This, unfortunately, increases server load and slows down admin page loading times. All of these can hamper other essential tasks and negatively impact user experience.
If you suspect that plugins are causing this issue, switch to more lightweight alternatives. But first, you need to identify these plugins. Using Query Monitor, here’s what you need to do.
Click on Query Monitor in the toolbar and go to the "Queries by Component" tab. This section categorizes and displays the performance impact of different components of your WordPress site, including plugins.
Now, review the performance metrics under the "Queries by Component" tab to identify plugins consuming significant resources. Look for plugins with high database query times. These should be visible on the right side of the table.
Next, you need to temporarily disable plugins that show high resource consumption. Then, observe any improvements in backend performance. Doing so should pinpoint which plugins are causing slowdowns in the WordPress admin area.
If disabling a plugin improves performance, consider reaching out to the plugin’s author for support. They may provide updates or optimizations. Alternatively, explore alternative plugins that offer similar functionality but with better performance.
Finally, keep an eye on your backend performance by regularly using Query Monitor. It's a great way to ensure your plugins are running smoothly. Don't forget to optimize and update plugins to keep everything in top shape.
Other Tips to Speed Up Your WordPress Admin Page
Query Monitor is great, but it's not the only trick up our sleeve! Let's look at some other ways to give your WordPress site a speed boost. Here are a few of our recommendations:
- Update WordPress and Plugins: Keep WordPress core and all plugins up-to-date for the latest performance improvements and security fixes.
- Optimize PHP Version: Upgrade to a supported PHP version (7.4 or higher recommended) for better performance and security.
- Use Site Health: The site health feature runs a series of tests to look for common performance and security issues on a WordPress website, from outdated themes and plugins to configuration issues. Use this built-in tool to monitor and improve the overall health and performance of your site.
- Optimize Database: Clean up and optimize your WordPress database regularly to remove unnecessary bloat.
- Upgrade Hosting: Consider a more robust hosting plan, such as managed WordPress hosting or a dedicated server.
- Increase PHP Memory Limit: Adjust this setting in wp-config.php to handle larger tasks without memory errors.
In Summary
Query Monitor is effective at tracking down and fixing issues that slow down a WordPress website. It’s got all the features you need for detecting common performance issues, from slow database queries to PHP errors.
What we really like about this plugin is that you don’t have to add extra code or use dedicated tools (like XDebug or third-party monitoring services) to test your site’s performance. The Query Monitor plugin gives you all the information you need to troubleshoot your site. That's why developers and site owners rely on it. It’s easy to use, too.
So, if you’re struggling with a slow website, then using a Query Monitor might help. It's definitely worth checking out.