Fill in your details optional The prompt below updates as you type. What you type stays in this browser and is never sent to us.
You are an expert in this kind of work, and you know the Marketing & Advertising sector from the inside.
## Your task
This query is slow on a [DATABASE] database at a marketing agency running campaigns for several clients. Table sizes: [ROW COUNTS]. Explain why it is slow, rewrite it, suggest indexes (with CREATE INDEX statements) and tell me what to look for in EXPLAIN to confirm the improvement.
## About my situation
- Who this is for: brand managers and marketing directors
- What we must respect: client brand guidelines and advertising regulations
- How we measure success: cost per acquisition and return on ad spend
## What matters in Marketing & Advertising
- Rules and standards that usually apply: advertising standards (FTC in the US, ASA in the UK, ASCI in India); clear labelling of paid and influencer content; consent rules for email, SMS and tracking (GDPR, CAN-SPAM, India's DPDP Act); trademark and copyright in creative work; Meta and Google ad policies.
- Common risks to plan for: scope creep and missed deadlines; client churn; ad account suspensions; claims that cannot be proved; overspending a budget.
- Tools commonly used: Google Ads; Meta Ads Manager; GA4; HubSpot; Canva or Figma; Semrush.
- Words people in this field use: brief; creative; media plan; flight; retainer; funnel (TOFU/MOFU/BOFU); attribution; lookalike audience.
- Rules differ by country. If I have not said where I work, ask me, and do not present one country's law as if it applied everywhere.
## What I will give you
Query:
[PASTE QUERY]
Schema:
[PASTE SCHEMA]
## How to work through it
1. Read the query and schema and explain how the database will execute it.
2. Point out what makes it slow (full scans, bad joins, functions on indexed columns, N+1 patterns).
3. Rewrite the query.
4. Suggest indexes with CREATE INDEX statements and their trade-offs.
5. Explain what to look for in EXPLAIN before and after.
## What to deliver
- Why it is slow
- The rewritten query
- Index statements
- EXPLAIN checklist
- Expected improvement
## Rules
- Make every point specific to my situation and my industry; replace generic advice with detail that fits.
- Use plain language, short sentences, and tables where they make the answer easier to scan.
- Use only the facts I give you. Do not invent figures, laws, sources or quotes. Mark anything you had to assume with "Assumption:".
- If something important is missing, ask me up to 3 short questions before you start.
## Before you answer
Check your draft against this list and fix anything that fails:
- The code works as written: no invented libraries, functions or APIs, and versions are named where they matter.
- It is written for a marketing agency running campaigns for several clients; nothing in it would read the same for any other business.
- Nothing in it breaks client brand guidelines and advertising regulations.
- Every item under "What to deliver" is included.
How to use this prompt
- Copy the prompt. Press Copy prompt and the full text goes to your clipboard.
- Fill the brackets. Use the form above, or replace [DATABASE], [ROW COUNTS], [PASTE QUERY], [PASTE SCHEMA] with your own details.
- Paste and send. Paste it into ChatGPT, Claude and DeepSeek and send. Ask follow-up questions to refine the answer.
Why this prompt works
The “Optimise a slow SQL query” prompt tells the assistant exactly what to hand back: why it is slow; the rewritten query; index statements; EXPLAIN checklist; and expected improvement. It makes the assistant work through 5 steps in order, starting with "read the query and schema and explain how the database will execute it", instead of jumping straight to an answer. Before replying, the assistant checks its draft against 4 tests and fixes anything that fails.
This version is written for a marketing agency running campaigns for several clients, so the assistant keeps client brand guidelines and advertising regulations in mind and judges the result by cost per acquisition and return on ad spend. If an important detail is missing, it asks you up to 3 short questions before it starts.
How to get the best answer
- Fill every bracket with real detail: [DATABASE], [ROW COUNTS], [PASTE QUERY] and the rest should hold real names, numbers and dates, not placeholders.
- Paste real material: where the prompt asks for notes, data or text, paste the actual content rather than a summary.
- Refine in the same chat: ask "make it shorter", "turn it into a table" or "add more detail on step 2".
- Check the result: review it against what you know about cost per acquisition and return on ad spend before you share it.
Other industries
Same prompt for other industries
The same optimise a slow sql query prompt, rewritten for each industry.
FAQ
Frequently asked questions
Which AI assistant works best with the “Optimise a slow SQL query” prompt?
The “Optimise a slow SQL query” prompt works in any chat assistant and suits ChatGPT, Claude and DeepSeek best. Paste it in, send it, and ask follow-up questions in the same chat to refine the answer.
What do I fill in before sending the “Optimise a slow SQL query” prompt?
Replace the 4 highlighted brackets – [DATABASE], [ROW COUNTS], [PASTE QUERY], [PASTE SCHEMA] – with your own details. The more specific you are, the better the answer.
Is the “Optimise a slow SQL query” prompt only for Marketing & Advertising?
No. This version is written for a marketing agency running campaigns for several clients, and the same prompt is also written for 15 other industries, listed on this page.
Is the “Optimise a slow SQL query” prompt free to use?
Yes. First AI Prompt prompts are free to copy and use in personal and business work, with no sign-up, no account and no daily limit.
Can I trust the answer the “Optimise a slow SQL query” prompt gives?
Treat it as a strong first draft: the prompt tells the assistant not to invent facts and to mark its assumptions, but check figures yourself, especially anything with legal, financial or safety consequences.
Keep exploring
Browse more Marketing & Advertising prompts
- All Marketing & Advertising prompts
- Project Managementfor Marketing & Advertising
- Marketing & Contentfor Marketing & Advertising
- SEOfor Marketing & Advertising
- Salesfor Marketing & Advertising
- Customer Supportfor Marketing & Advertising
- Data Analysisfor Marketing & Advertising
- Business Strategyfor Marketing & Advertising
- Operationsfor Marketing & Advertising
- Browse the full library