Course overview
Lesson 6 of 9 · 3 promptsAI for Data Architects
LESSON 06 OF 9

Optimizing Queries And Storage

3 prompts for Data Architects

Prompts for Data Architects: copy one, fill it in, paste it into your AI.

Track progress as a member

In this lesson

  1. 01Rewrite A Slow SQL QueryUse this when you have a query that is underperforming and you want rewritten alternatives plus a clear explanation of why each should be faster.
  2. 02Explain Partitioning Strategy For Large TablesUse this when you need to justify partitioning, clustering, or indexing choices for a large table to your team.
  3. 03Estimate Storage And Growth NeedsUse this when you are sizing a warehouse or planning capacity and need help turning row counts and growth rates into storage estimates.
1Copy the promptClick Copy on the prompt you need.
2Paste it into your AIChatGPT, Claude, Gemini or Copilot.
3Fill in the {{brackets}}Your own details, or let the AI ask you.
4Follow up and checkUse the follow-ups, then check the facts.
01

Rewrite A Slow SQL Query

Use this when you have a query that is underperforming and you want rewritten alternatives plus a clear explanation of why each should be faster.

Prompt

Role You are a database performance engineer who rewrites slow SQL for data architects. Optimise for identical results first, then clarity, then speed, and explain each change so the requester can defend it.

Context you provide

  • {{database_engine}} - engine and edition
  • {{engine_version}} - version string
  • {{original_query}} - the SQL as it runs today
  • {{execution_plan}} - EXPLAIN or plan output if available
  • {{table_and_index_ddl}} - CREATE statements for tables, indexes, keys
  • {{data_shape}} - approximate row counts, cardinality, skew
  • {{measured_runtime}} - current timing and how it was measured
  • {{target_runtime}} - acceptable latency
  • {{business_meaning}} - what the result set must represent
  • {{constraints}} - read-only, no schema change, dialect limits

Instructions

  1. Ask for any missing inputs, then restate the query's intent in one sentence and ask me to confirm it.
  2. Diagnose likely causes of slowness from the plan and DDL: full scans, unused or missing indexes, non-sargable predicates, implicit conversions, unnecessary sorts, poor join order.
  3. Write two or three rewritten variants, ordered from least to most invasive.
  4. For each, name the operator or step it removes and why that reduces work.
  5. List index or schema changes separately as recommendations, never as silent edits inside the query.
  6. State what to check after running: result parity, plan shape, timing.

Output format Per variant: a heading, the SQL in a code block, "Why it should be faster" bullets, "Trade-offs" bullets, and a "Verify" line. Close with a short comparison table of the variants. Tight prose, no SQL tutorials, no filler.

Guardrails

  • Use only the table, column and index names supplied; never invent them or any statistic.
  • Do not promise a speedup percentage unless the plan supports it; describe direction and the operator affected.
  • Flag when a change needs a DBA, a migration window, or a check against the engine's own documentation before production.

Example Engine: PostgreSQL 15; query joins orders to customers and filters on a text date column; plan shows a sequential scan and a hash join spilling to disk.

Open as its own page

02

Explain Partitioning Strategy For Large Tables

Use this when you need to justify partitioning, clustering, or indexing choices for a large table to your team.

Prompt

Role You are a data architect who explains partitioning, clustering, and indexing choices for large tables. Optimise for a clear, justified recommendation your team can act on.

Context you provide

  • {{table_name}} - the large table under discussion.
  • {{row_count}} - approximate number of rows.
  • {{data_volume}} - total size on disk (e.g., GB or TB).
  • {{growth_rate}} - new rows or data added per day or month.
  • {{query_patterns}} - common queries, filters, joins, and aggregations.
  • {{common_filters}} - columns most often used in WHERE clauses.
  • {{join_keys}} - columns used to join this table to others.
  • {{existing_indexes}} - current indexes and their columns.
  • {{database_engine}} - the database or warehouse platform.
  • {{business_goals}} - e.g., reduce query latency, lower storage cost, improve load time.
  • {{constraints}} - e.g., maintenance windows, budget, team skills.
  • {{audience}} - who will read this (engineers, analysts, managers).

Instructions

  1. Ask for any missing inputs, then wait for my reply before continuing.
  2. Summarise the table's size, growth, and workload in two or three sentences.
  3. Evaluate partitioning options (range, list, hash) against the query patterns and filters.
  4. Compare clustering and indexing choices for the same workload.
  5. Recommend one strategy, with trade-offs for query speed, storage, and maintenance.
  6. Outline a step-by-step migration or implementation plan, including rollback.
  7. Explain how to measure success after the change.
  8. Flag any assumptions and note where a database administrator or vendor manual must be consulted.

Output format Use markdown with these sections: Summary, Options Compared (a table), Recommendation, Trade-offs, Implementation Steps, How to Measure Success, Assumptions and Checks. Keep it under 600 words. Use plain language for non-engineers, but include column names and query patterns. Leave out vendor-specific syntax unless I provide it. Do not invent benchmarks or row counts.

Guardrails

  • Do not invent figures, row counts, or performance numbers. Use only what I provide.
  • Flag every assumption clearly and state what would change the recommendation.
  • Tell me when a licensed database administrator, a local regulation, or a vendor manual must be checked before making changes.

Example Table: events, 2B rows, 1.5 TB, 10M new rows/day, queries filter by event_date and user_id, Postgres, goal: cut query time and storage cost.

Open as its own page

03

Estimate Storage And Growth Needs

Use this when you are sizing a warehouse or planning capacity and need help turning row counts and growth rates into storage estimates.

Prompt

Role You are a data architect producing defensible storage sizing estimates. Optimise for visible assumptions the reader can adjust, not one confident number.

Context you provide

  • {{tables_and_purpose}}: each table, what it holds, and its grain
  • {{row_counts}}: current rows per table with the as-of date
  • {{bytes_per_row}}: average row size, or the columns that drive it
  • {{growth_rate}}: rows added per month, or percent growth
  • {{retention_rules}}: keep, archive and delete windows
  • {{copies}}: replicas and backups, with retention
  • {{overhead_factors}}: indexes, compression, metadata
  • {{horizon_and_tiers}}: planning window and storage tiers

Instructions

  1. Ask for any missing inputs, then use only what is supplied.
  2. Convert rows and row size into a current size per table, then a total.
  3. Apply the growth rate across the horizon and project size at each interval.
  4. Apply retention, copies and overhead as separate labelled multipliers.
  5. Give low, expected and high scenarios within a stated range.
  6. Name the two or three assumptions that move the estimate most.
  7. Note what to confirm with platform documentation or finance.

Output format A table of current size, projected size at horizon, and each multiplier applied, then brief bullets on assumptions, key drivers and next checks. Under 500 words. Plain language for a stakeholder. Omit vendor claims and unrequested cost estimates.

Guardrails

  • Never invent row sizes, compression ratios, storage prices or platform limits; label anything not supplied as an assumption to confirm.
  • Show the arithmetic so the reader can reproduce every figure.
  • Tell the user to verify platform limits and pricing in official documentation and with finance before committing to capacity.

Example Tables: orders (240M rows, 1.1 KB/row), events (3.2B rows, 400 B/row); growth 8% per month; 36-month horizon; 2 replicas; 90-day backups.

Open as its own page

Skills for these tasks

Give your AI these skills and it does these tasks the expert way. Connect your AI once and it picks them up by itself.