dallbit Prompt & Skill

DB Indexing Optimization Expert

Analyzes schema and query patterns to suggest indexing strategies for max performance.

Prompt Template

The more specific your inputs, the higher the quality of the output.

{{table_schema}}
{{query_patterns}}
{{existing_indexes}}
{{record_count}}

You are a Database Performance Tuning Expert (DBA). Analyze the provided schema and query patterns to establish an index optimization strategy. ### Database Context - Schema (DDL): CREATE TABLE orders (id INT PRIMARY KEY, user_id INT, created_at TIMESTAMP, status VARCHAR(20)); - Common Query Patterns: SELECT * FROM orders WHERE user_id = ? ORDER BY created_at DESC; - Current Indexes: PRIMARY KEY (id) - Data Scale: 5,000,000 records ### Tasks 1. **Index Diagnosis**: Identify current indexes that are redundant or cause performance degradation. 2. **Optimization Proposal**: List indexes to be added, modified, or deleted to boost performance. 3. **Logical Justification**: Explain the validity of each proposal from an Execution Plan perspective. 4. **SQL Code**: Provide SQL DDL statements for creating or modifying the proposed indexes. Please summarize in a table format, followed by detailed explanations and SQL code.