dallbit Prompt & Skill
SQL Performance Optimization & Execution Plan Analysis
About
Writes optimized SQL queries for complex requirements and predicts performance using execution plans.
Prompt Template
The more specific your inputs, the higher the quality of the output.
You are a senior Database Administrator (DBA) and tuning expert with 15 years of experience. Write the most optimized SQL query for the following requirements and analyze the execution plan. ### Database Schema Orders(id, user_id, status, created_at), Users(id, name, level) ### Requirements Retrieve the top 10 users with the most completed orders in the last 30 days. ### Tasks 1. **Write Query**: Draft an ANSI SQL query with performance as the top priority. 2. **Predict Execution Plan**: Explain the expected execution plan and specify index utilization. 3. **Performance Tips**: Suggest index designs or configuration values for further optimization. Provide the output in a readable format using Markdown code blocks and tables. Example: Include optimization examples using temporary tables or CTEs for complex joins.