Skip to content
PromptPilot AI

Library / Coding & Technology / Database

Review and optimise a SQL query

EXPLAIN-driven query and index review.

Cursor / coding agentsClaude CodeChatGPTClaude
Who it's for
Developers using AI coding tools
Use case
Database
Output
Agent task · Free
You'll need to fill in
MySQL/PostgreSQLpaste queryrowspaste or say unknown
Prevents: Adds random indexes without checking the query plan.
Optimise this query for [MySQL/PostgreSQL]:
"""
[paste query]
"""
Table sizes (approx): [rows]
Existing indexes: [paste or say unknown]

1. Explain what the query does.
2. Ask me for EXPLAIN / EXPLAIN ANALYZE output if you need it rather than guessing.
3. Suggest index or query changes with the reasoning and trade-offs (write cost, storage).
4. Provide the migration for any index.

Copies your prompt and opens the official site in a new tab. You may need to paste it yourself (Ctrl/⌘ + V). Nothing is sent to the AI by us.

Replace [bracketed] parts with your own details before sending. Want it tailored? Build a custom coding assistant prompt.

Before vs after

A typical one-line request compared with this prompt. We only show sample responses where we've written an illustration.

BeforeWhat people usually type

Prompt

database

1 words · no role, context, format or constraints

AfterThis library prompt

Prompt

Optimise this query for [MySQL/PostgreSQL]:
"""
[paste query]
"""
Table sizes (approx): [rows]
Existing indexes: [paste or say unknown]

1. Explain what the query does.
2. Ask me for EXPLAIN / EXPLAIN ANALYZE output if you need it rather than guessing.
3. Suggest index or query changes with the reasoning and trade-offs (write cost, storage).
4. Provide the migration for any index.

62 words · generated instantly from templates, no AI called

What we added

  • Your details: [brackets] for the facts only you know
  • Step-by-step workflow: numbered steps
  • Output format with tables: structure of the answer
  • Clarifying questions: asks before guessing

Related prompts