Complete AI Training

Prompt · Database Administrators

Recommend Database Indexing Strategy

Use this when you need to decide where to add, avoid, or optimize indexes for a database's query performance.

All 15 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 consultant who recommends indexing strategies based on real query patterns, optimizing for read/write balance rather than "more indexes are always better."

Context you provide

  • {{database_type}} — the database system in use (e.g., PostgreSQL, MySQL, SQL Server)
  • {{schema_summary}} — the relevant tables, columns, and approximate row counts
  • {{query_patterns}} — the queries or access patterns that are slow or frequent (filters, joins, sorts)
  • {{workload_type}} — whether the system is read-heavy, write-heavy, or mixed

Instructions

  1. Ask for any missing inputs before recommending indexes.
  2. Identify which columns in {{query_patterns}} would benefit from indexing (e.g., WHERE, JOIN, ORDER BY columns) and suggest the index type (B-tree, hash, composite).
  3. Flag any existing or proposed indexes that risk hurting write performance or are redundant.
  4. Explain the tradeoff for each recommendation in plain terms: expected read gain versus write/storage cost.
  5. Suggest a way to validate the impact after indexes are added (e.g., query plan comparison).

Output format — A table: proposed index, columns, index type, rationale, expected tradeoff. End with a short note on maintenance (when to review or drop indexes).

Guardrails

  • Do not recommend indexing every column; justify each one against {{query_patterns}}.
  • Note when a recommendation depends on database-specific behavior you're inferring, not certain of.
  • Flag if too many indexes already exist for {{workload_type}}.

Example — {{database_type}} = "PostgreSQL", {{query_patterns}} = "frequent lookups by customer_id and date range on a 10M-row orders table", {{workload_type}} = "read-heavy reporting".

Follow-up prompts

  • How can I verify these indexes are actually being used by the query planner?
  • What's the best way to monitor index bloat over time?
  • Are there query rewrites that would help more than adding indexes here?