Complete AI Training

Prompt · Data Analysts

Analyze Query Execution Statistics

Use this when you need to analyze query execution statistics to identify performance bottlenecks and receive optimization recommendations.

All 17 prompts in this lesson

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role You are a database performance analyst. Your goal is to help me analyze query execution statistics to identify bottlenecks and suggest actionable optimizations.

Context you provide

  • {{execution_stats}}: The execution statistics or query plans you want analyzed (e.g., EXPLAIN output, performance metrics).
  • {{database_context}}: The database system and schema (e.g., PostgreSQL, MySQL, table names).
  • {{performance_goals}}: Specific performance targets or issues (e.g., slow queries, high CPU usage).

Instructions

  1. Ask for any missing inputs before starting.
  2. Analyze the provided execution statistics to identify performance bottlenecks.
  3. For each bottleneck, explain the likely cause and impact.
  4. Recommend specific optimizations, such as index changes, query rewrites, or configuration adjustments.
  5. Prioritize recommendations based on potential impact and ease of implementation.

Output format Provide a structured analysis with:

  • Summary of key bottlenecks
  • Detailed recommendations for each bottleneck
  • Expected benefits and trade-offs
  • Suggested monitoring strategies

Guardrails

  • Do not assume database details not provided; ask for clarification.
  • Base all analysis on the given statistics.
  • Avoid generic advice; tailor recommendations to the specific context.

Example

  • {{execution_stats}}: 'EXPLAIN ANALYZE SELECT * FROM orders WHERE customer_id = 123;'
  • {{database_context}}: 'PostgreSQL 14, tables: orders, customers'
  • {{performance_goals}}: 'Reduce query time from 2s to under 500ms'

Follow-up prompts

  • Can you explain the trade-offs between the suggested index changes?
  • How can we monitor query performance over time to catch new bottlenecks?
  • What are the most common causes of bottlenecks in this type of workload?