prompt
FreeSQL expert assistant prompt with best practices for query writing, optimization, and schema design.
FreeFree tier
Inputs: textOutputs: text
About prompt
System prompt for an AI assistant specialized as a senior database engineer and SQL expert. It covers SQL query writing, schema design, query optimization, and database architecture across PostgreSQL, MySQL, SQLite, BigQuery, Snowflake, and DuckDB. The prompt includes detailed instructions for writing correct, readable, performant SQL, diagnosing slow queries, designing normalized schemas, and handling dialect-specific nuances. It enforces best practices such as explicit JOINs, CTEs, proper indexing, surrogate keys, and precise data types.
Key Features
Covers PostgreSQL, MySQL, SQLite, BigQuery, Snowflake, and DuckDB
Detailed instructions for SQL query writing with explicit JOINs and CTEs
Query optimization diagnostic approach using EXPLAIN ANALYZE and specific fixes
Schema design principles: normalization, surrogate keys, precise column types
Dialect awareness: flags syntax differences across databases
Includes rules for aggregations, window functions, recursive CTEs
Trade-off analysis for index maintenance, write amplification, vacuum pressure
Guidance on soft deletes and audit trails
Pros & Cons
Pros
- Covers a wide range of modern SQL databases and dialects
- Emphasizes best practices like explicit JOINs, CTEs, and proper indexing
- Provides a structured approach to optimization with concrete fix suggestions
- Includes schema design principles with rationale for each choice
- Dialect awareness helps avoid common cross-database pitfalls
- Open source and freely available on GitHub
Cons
- Requires an external AI model to interpret and execute the prompt; no standalone tool
- Not an interactive tool with a GUI; purely text-based guidance
- Does not include examples or sample databases for practice
- Optimization and schema advice may become outdated as databases evolve
- Limited to the knowledge embedded in the prompt; cannot run actual queries
Best For
Writing performant SQL queries across multiple database systemsDiagnosing and optimizing slow database queriesDesigning normalized database schemas for new applicationsLearning SQL best practices and dialect-specific syntaxReviewing and improving existing database schemas and queriesArchitecture advice for database migration or multi-dialect projects
FAQ
What databases does this SQL assistant prompt support?
It explicitly covers PostgreSQL, MySQL, SQLite, BigQuery, Snowflake, and DuckDB. Defaults to PostgreSQL unless told otherwise.
Does the prompt include instructions for query optimization?
Yes, it includes a step-by-step optimization approach: ask for EXPLAIN ANALYZE, identify the bottleneck, propose a specific fix with trade-offs, and estimate impact. It also flags common patterns like SELECT * in subqueries and OFFSET pagination.
What schema design principles does the prompt recommend?
It recommends normalizing to 3NF by default, using surrogate keys (UUID or bigserial), NOT NULL by default, precise column types, stating index needs, and flagging missing foreign keys. It also suggests using deleted_at for soft deletes and created_at/updated_at for audit trails.