Paste the slow query along with the database engine, approximate table
sizes, current execution time, and any existing indexes, and this prompt
diagnoses the real bottleneck — a full table scan, a missing index, an
unnecessary join — before rewriting the query for performance. It
proposes concrete CREATE INDEX statements, estimates the expected
speedup, and suggests an alternative like a materialized view or
pre-aggregation when a rewrite alone won't be enough, showing
before-and-after versions with an explanation for each change.
Describe the database engine, the available tables with their columns
and relationships, the analysis you need in plain English, and whether
to optimize for large tables or readability, and this prompt writes the
production-ready SQL query to get there. It handles nulls sensibly, uses
CTEs to keep complex logic readable, comments any non-obvious steps, and
returns business-friendly column names instead of raw
database_column_names — useful whenever you know the analysis you want
but not the SQL to write it.
List the filter dimensions users can apply, the key metrics shown, the
drill-down hierarchy, the comparison periods needed, the database
engine, and the relevant tables, and this prompt writes the
parameterized SQL query layer behind an interactive dashboard. Each
panel's query accepts filter parameters using {{parameter_name}} syntax,
returns data shaped for its visualization, is written for sub-second
interactive response, and handles edge cases like empty filters meaning
"all data" or invalid date ranges.