Slow queries
DebugHawk identifies database queries that take longer than your configured threshold and flags them as slow queries. Slow queries are one of the most common causes of a slow WordPress site, especially in the admin, where heavy plugins run far more queries per request.
How slow queries are detected
DebugHawk monitors every database query during page generation. When a query exceeds your slow_queries_threshold setting (50ms by default), it's captured and sent to DebugHawk along with detailed execution information.
The system captures up to your configured slow_queries_limit (3 by default) per request, focusing on the slowest queries.
Understanding the data
Each slow query record includes:
- Query: The actual SQL statement that was executed
- Duration: How long the query took to complete (in milliseconds)
- Component: The WordPress component (core, plugin, theme) that generated the query
- Location: The PHP file and line number where the query originated
- When: Timestamp of when the query was executed
Configuration
Slow query detection is controlled by two settings in your wp-config.php. See configuration for the full list of options.
define( 'DEBUGHAWK_CONFIG', [
'slow_queries_threshold' => 50, // Flag queries over 50ms
'slow_queries_limit' => 3, // Capture up to 3 per request
] );
Threshold recommendations
- 50ms (default): Suitable for most WordPress sites
- 25ms: More aggressive threshold for high-performance sites
- 100ms: Relaxed threshold for sites with expected database load
Limit considerations
The default limit of 3 slow queries per request balances monitoring completeness with data volume.
Reading slow queries in the dashboard
Start with the component column. If one plugin or theme accounts for most of your slow queries, that's where to focus. The location tells you which PHP file and line ran the query, which is usually enough to find the hook or function responsible.
Next, look at where the slow queries happen. A slow query on a public page affects every visitor, unless the page is cached. A slow query in the admin affects your team, and often points to a plugin loading more data than it needs.
For example, a WooCommerce store might see a 300ms query from a reporting plugin on every admin page load. Moving that work to a scheduled task, or only loading it on the reports screen, removes it from every other request.
Related
- Outgoing requests: the other common source of slow backend time
- Data aggregation: how query durations are summarized across requests
- WordPress performance report: real-world database timings across 5.7 million pageviews