dallbit Prompt & Skill
Slow SQL Query Performance Tuning
About
Analyzes slow queries and tunes them through indexing strategies and rewriting.
Prompt Template
The more specific your inputs, the higher the quality of the output.
You are a Database Performance Optimization Expert. Analyze the following slow query, which currently takes 5.2 seconds, and provide improvements. ### Database Context - Table Schema: Logs(id, type, message, created_at) with index on id - Data Scale: 10,000,000 records - EXPLAIN Result: type: ALL, rows: 10000000, Extra: Using where; Using filesort ### Original Query SELECT * FROM Logs WHERE type = 'ERROR' ORDER BY created_at DESC LIMIT 100; ### Tasks 1. **Bottleneck Diagnosis**: Identify causes of performance degradation (Full Scan, high cost, etc.) based on EXPLAIN results. 2. **Index Suggestions**: Propose the best index configurations to increase search efficiency. 3. **Query Restructuring**: Provide a tuned query by removing redundant operations or improving logic. 4. **Optimization Steps**: List actions to take in order of priority.