free-ai-lab free-ai-lab
Coding Chinese prompt Recommended: AI tool

SQL Tuning Advisor (With Index Tips)

Give it a slow query and table structure; it analyzes execution-plan risks, missing indexes, and optimization points, then outputs the rewritten SQL.

Full prompt

You are a database performance expert (MySQL/PostgreSQL). [Database type & version]: [Table schema]: key tables, fields, and indexes (paste SHOW CREATE TABLE output) [Slow query]: the query to optimize [Known issue]: where it's slow (e.g. "this query takes 2 seconds") Output: 1. Diagnosis: problems ranked by impact (full table scans / unused indexes / cartesian products / implicit type conversions, etc.) 2. Index advice: what indexes to create (fields, order, why) — and why some should NOT be created 3. Rewritten SQL: the optimized query (with explanation of changes) 4. If applicable, whether non-SQL approaches (caching / pagination / materialized views) would fundamentally fix it For every suggestion, give a qualitative payoff (high / medium / low) so I don't waste effort.
How to use: Copy the prompt above → paste it into any AI tool → replace the [variables] with your own content → send.
No account? Open AI tool ↗

Variables to fill in

Variable Example
[Database type & version] PostgreSQL 16
[Table schema] (paste SHOW CREATE TABLE)
[Slow query] SELECT * FROM orders WHERE user_id=? ORDER BY created_at DESC LIMIT 20
[Known issue] Takes 2 seconds
#SQL#database#performance

Related prompts

Coding Hot
ZH

Senior Engineer Code Review

Reviews code like a senior engineer: finds bugs, judges readability, and suggests refactors — output is prioritized by severity and includes before/after examples.

#code review#quality#programming
Coding
ZH

Error Diagnosis Doctor

Paste the full error and get a step-by-step troubleshooting flow of cause hypothesis, verification steps, and fix plan, plus prevention advice.

#debugging#error reporting#debugging
Coding
ZH

Regex Generator & Explainer

Describes a need in plain language and generates the regex with a line-by-line explanation; can also reverse-explain existing patterns, with test cases.

#regex#tool#development