Query Optimizer¶
The Query Optimizer automatically tracks slow queries and provides AI-powered optimization recommendations. Available on paid plans only.
How it works¶
The agent automatically collects query performance data from MySQL's performance_schema:
- Queries are tracked over a 7-day rolling window
- Only queries with avg execution time ≥100ms are captured
- Query digests (normalized patterns) are stored, not actual data with values
- EXPLAIN plans are collected for analysis
- Schema and table information is tracked for context
No manual query input required—optimization happens automatically based on your real workload.
Query tracking tabs¶
Slow Queries tab¶
Shows queries exceeding the 100ms threshold, sorted by average execution time.
For each query you'll see: - Query digest - Normalized SQL pattern (click to view full details) - Schema - Database name (filterable) - Tables involved - Which tables are accessed - Avg/Max time - Execution time statistics - Executions - How many times the query ran - Rows examined - Total rows scanned - AI indicator - Lightbulb icon when AI recommendations are available - Bookmark - Pin important queries to the top
Sortable columns: Click headers to sort by time, executions, or rows examined.
Queries Missing Indexes tab¶
Automatically detects queries that performed full table scans or didn't use optimal indexes.
Shows queries where:
- sum_no_index_used > 0 (query didn't use any index)
- sum_no_good_index_used > 0 (query used a suboptimal index)
Sorted by impact: (executions without index × avg time) to prioritize high-impact queries.
Query details and optimization¶
Click any query to open the details modal:
- Query text - Full normalized SQL
- Performance stats
- Execution count
- Avg/Max/Total time
- Rows examined vs rows sent (scan efficiency)
-
Index usage statistics
-
EXPLAIN analysis
- JSON execution plan
- Table access methods
- Index usage per table
-
Join types and conditions
-
AI recommendations (click "Get AI Recommendations")
- Index suggestions with CREATE INDEX commands
- Query rewrite suggestions
- Schema design recommendations
-
Expected performance impact
-
Actions
- Bookmark - Pin this query for quick access
- Delete - Remove from tracking (query digest will be re-collected if it runs again)
- Copy - Copy query text or recommendations
Bookmarking queries¶
- Click the bookmark icon to pin important queries
- Bookmarked queries appear first in the list (highlighted in yellow)
- Use this to track queries you're actively optimizing
Schema filtering¶
Use the schema filter input at the top of the query table to show only queries from specific databases.
Best practices¶
- Review the "Missing Indexes" tab first for quick wins
- Bookmark queries you're actively working on
- Compare health scores before/after applying indexes
- Test index changes in staging before production
- Use the AI recommendations as guidance, not absolute rules
- Monitor the health chart to see impact of optimizations
- Check existing indexes before creating duplicates:
SHOW INDEX FROM table_name
Applying optimizations¶
AI recommendations provide exact SQL commands:
To apply:
1. Test in staging or dev environment first
2. Check current indexes to avoid duplicates
3. Run the CREATE INDEX command during low-traffic periods
4. Monitor query performance in the dashboard
5. Verify the index is being used: EXPLAIN SELECT ...
Query tracking limits¶
Your plan determines how many queries are tracked: - Plans typically allow tracking hundreds of unique query digests - Usage is displayed in the MySQL Optimizer header - When limits are reached, oldest/least-used queries may be pruned