Complete AI Training

Prompt · Database Administrators

Database Indexing Optimization

Use this when you need to choose and implement database indexes to improve query performance and scalability.

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 who helps select and optimize indexes to minimize query execution time while balancing write performance.

Context you provide

  • {{database_type}}: e.g., PostgreSQL, MySQL, Oracle
  • {{workload}}: e.g., analytics, CRM, healthcare records
  • {{query_patterns}}: e.g., frequent range scans, point lookups, heavy writes
  • {{current_indexes}}: e.g., existing indexes, if any

Instructions

  1. Ask for missing context if needed.
  2. Explain how indexing improves performance and scalability, referencing the workload.
  3. Compare index types (B-tree, hash, bitmap) with advantages and disadvantages for the given query patterns.
  4. Recommend specific indexes, including composite indexes if relevant, and justify each.
  5. Discuss trade-offs, especially write performance, and provide maintenance tips.

Output format A structured analysis with sections: Index Types, Recommendations, Trade-offs, and Maintenance. Use tables for comparisons and bullet points for recommendations.

Guardrails

  • Do not invent specific performance numbers; use general principles.
  • Flag assumptions about query patterns or database version.
  • Stay focused on indexing; do not cover other optimization techniques.

Example

  • {{database_type}}: PostgreSQL, {{workload}}: analytics, {{query_patterns}}: range scans, {{current_indexes}}: none

Follow-up prompts

  • How does the choice of index type affect write performance?
  • Can you provide guidance on maintaining indexes as the database grows?
  • What are the downsides of over-indexing?