AI Compare Ninja AI Compare Ninja

Compare AI tools. Use prompts and skills.

Language
EN

Speed up a slow database query

Prompt that reads a slow SQL query with its execution plan, finds the most expensive steps and suggests improvements with benefit and risk. Paste it into an AI tool of your choice, which then speeds up the query.

Topic
Coding & agents
Type
Prompt
Level
Intermediate
Time
about 8 min

Results depend on the tool, the model and what you enter.

Result preview

Example: written by our editors, not real AI output.

The query returns a customer's open orders from the last 90 days. Most expensive step: full scan of orders (1.2 million rows) because there is no index on (customer_id, status). Suggestion 1: index on orders (customer_id, status, created_at). Expected: run time from about 900 ms to under 20 ms. Side effect: slightly slower writes, about 40 MB more storage. Measure: EXPLAIN ANALYZE before and after, run time in monitoring for one week. Assumption: status has only a few distinct values.

Fill in

What you type stays in this browser window. We store and send nothing.

Which database do you use?
How often does the query run?
Paste the query, execution plan and index list, without real customer data

Your prompt

This is an instruction for an AI, not the result itself.

Where this prompt works

These AI tools are a good fit for this prompt:

How to use it

  1. Fill in the fields or tap a suggestion. Leave out names, addresses and other personal data.
  2. Copy the finished prompt into an AI tool of your choice.
  3. Test every suggestion on a copy with a realistic amount of data first and compare run time and result before you deploy it.

Why does this work?

The execution plan shows where the time is really lost. Naming the cost for writes avoids indexes that slow things down elsewhere.

Tips

  • An execution plan with real timings, for example from EXPLAIN ANALYZE, says much more than the estimated version.

Part of these agents

Performance agent

Also a good fit

You may use our prompts freely, including at work. Please do not republish them as your own collection. We give no warranty for AI results; check them yourself. Terms of use