Getting Started

Deployment Deployment - Diagnose Migrations Staging

Site Management

Backups Client Reporting Passwords Plugin Automation Plugin Management - Global Plugins & Themes - Diagnose Plugins & Themes - General Plugins & Themes - Git Plugins & Themes - Logs Must Install White Label WordPress Updates

Caching & Performance

Caching Caching - Blogs/Articles Caching - Diagnose Caching - Git Caching - WooCommerce Redis Optimize & Scale

Security

Security Security - Firewall

SMTP, CDN & DNS

SMTP SendGrid CDN CDN - AWS CDN - Cloudflare CDN - Diagnose Domains & DNS

Server & Tools

Analytics & Logs CRON Jobs Database Debug Tool Git Monitoring PHP Settings Redirects SEO Tools Server Errors sFTP SSL

Staq Billing

Staq Billing > Account Staq Billing > Client Staq Billing > Setup

Media

Media Media - Diagnose Media - Optimize

Accounts & Billing

Accounts & Billing

General

WordPress Hosting Website Diagnose Troubleshoot - Other

How to use Staq Query Tool to diagnose database queries


On this page

    This guide explains how to diagnose database query bottlenecks in a WordPress website using the Staq Query Tool. Follow the steps below to identify and analyze slow database queries effectively.

    Debugging Database Queries with Staq Query Tool

    1. Accessing the Query Tool

    • Log in to your WordPress dashboard.
    • Navigate to Staq Hosting in the menu.
    • Click on Advanced under the Staq Hosting menu.
    • Select Monitor from the dropdown menu.

    2. Enabling the Monitor

    • On the Monitor page, click Enable monitor to start tracking queries.
    • Optionally, enable Monitor hooks to track action or filter hooks, which is useful if you suspect a specific hook is causing delays.

    3. Reproducing the Issue

    • After enabling the monitor, visit the problematic page or perform the action you suspect is causing the issue.
    • Reproduce the problem (e.g., refreshing a page, updating content) to log the relevant query data.

    4. Viewing the Debug File

    • Return to Staq Hosting > Advanced > Monitor.
    • Click View debug file.
    • If needed, append a custom query string (e.g., ?your-custom-tag) to the URL to make specific entries easier to locate in the debug file.
    • The debug file will provide a detailed list of all executed queries, their execution times, and any related hooks.

    5. Analyzing the Debug Information

    • Review the queries to identify any that take longer than expected.
    • Check for related hooks or functions to pinpoint if plugins or themes are responsible for the delays.
    • Pay attention to queries that are repeatedly executed or those not using database indexes efficiently.

    Example: Diagnosing a Database or Plugin/Theme Query Issue

    Here’s an example of how we used the Staq Query Tool to identify whether an issue was caused by database queries or plugins/themes:

    1. Enabled the debug feature in the Staq Hosting plugin.
    2. Visited the problematic page and saved it to reproduce the issue.
    3. The debug tool logged data during the save operation, tracking the speed of queries.
    4. The “DB Time” recorded was 0.3458 seconds, indicating fast database performance.
    5. A significant time difference between wp_loaded and shutdown suggested the problem was related to a plugin or theme.
    6. Turned off the debug function to prevent performance impacts while it was no longer needed.
    7. Continued diagnosing with tools like Query Monitor to further isolate the issue.

    Additional Resources

    If you’d like to learn how to diagnose PHP queries and identify slow plugins or themes, check out our guide on using the Query Monitor plugin.

    Need some help?

    We all do sometimes. Please reach out to our support team by dropping us a support ticket. We will respond fast.