Roundup
SQL is where a coding model can do the most damage with the fewest keystrokes. One missing WHERE on a DELETE, one DROP against the wrong schema, one migration that locks a table under production load — and there's no undo button on a live database. So this is the roundup where our loudest advice isn't which model to pick, it's review every generated statement and guard destructive operations before they touch anything real. The model choice matters, but the safety habit matters more. The live board is at /benchmarks (VCI = SWE 40 / TB 30 / LCB 30).
And the honest caveat up front: there is no canonical SQL benchmark with the authority SWE-bench Verified has for Python. So this ranking leans on general reasoning ability and real-world reports, then hands the deciding vote to your own schema. Test the shortlist on a copy of your database, never production.
Why the Python benchmark still tells you something
General coding ability transfers. A model that reasons carefully across real Python repos also reasons carefully about joins, set logic, and query structure. So SWE-bench Verified isn't a SQL ranking, but it's a reasonable starting signal for which models think clearly about correctness — which is precisely what you want near a database. Use it to build a shortlist, not to crown a winner. The numbers below are general, not SQL-specific — that caveat is the point.
| Model | SWE-bench Verified (general proxy) | Why it matters for SQL |
|---|---|---|
| 95.0 | Top ceiling for gnarly analytical queries and CTEs | |
| 88.6 | The safe default — careful, precise, half of Fable's price | |
| 85.2 | High-volume queries and routine migrations | |
| 80.6 | Strong all-rounder, comfortable across dialects | |
| 79.3 | 167 tok/s — fast query drafting | |
| 77.6 | $0.435 / $0.87 per M — cheap high-volume query work | |
| 77.3 | 204 tok/s — fastest here, great for rapid drafts | |
| 75.6 | Strong self-contained problem-solving (LCB 88.5) |
What actually matters for SQL specifically
Three things swing SQL work that a general board doesn't capture.
Destructive operations. The single biggest risk. A model asked to "clean up test rows" can generate a DELETE that's correct in intent and catastrophic in scope. Always read the WHERE clause yourself, run against a copy first, wrap changes in a transaction you can roll back, and never let an agent execute DROP, TRUNCATE, or an unscoped UPDATE/DELETE without an explicit human gate.
Query plans and performance. A query can be correct and still bring your database to its knees — a missing index, an accidental cross join, a subquery that runs per row. Models are getting good at flagging these, but they don't see your data volume or your EXPLAIN output unless you show them. Paste the plan; ask the model to reason about it rather than trusting it to guess.
Dialect drift. Postgres, MySQL, SQL Server, SQLite, and the analytics engines all differ in syntax, functions, and locking behavior. A model may hand you Postgres-flavored SQL for a MySQL database. State your engine and version explicitly, every time.
Speed versus ceiling for SQL work
Drafting a routine query or a straightforward migration is fast, iterative work — Gemini 3.5 Flash at 167 tok/s and Qwen3.7 Max at 204 tok/s make it pleasant, and their ceiling is plenty for everyday selects and joins. Save the frontier models for the hard part: a window-function-heavy analytical query, a tricky many-to-many migration, or anything where a subtle logic error corrupts data silently.
DROP/DELETE/UPDATE, test on a copy, and wrap changes in a rollback-able transaction.Picks by SQL workload
- Complex analytical queries. Reasoning ceiling wins. Opus 4.8 as the default; Fable 5 for the intricate CTEs and window functions where one wrong join silently doubles a count.
- High-volume routine queries and migrations. Sonnet 5, or DeepSeek V4 Pro for value — capable and cheap enough to run all day. Still review every migration.
- Fast query drafting. Gemini 3.5 Flash or Qwen3.7 Max, then you verify and run it yourself.
- All-rounder across dialects. GPT-5.5 is a strong single choice, comfortable switching between Postgres, MySQL, and the rest.
How to actually test on your stack
This beats every roundup and takes an afternoon — on a copy of your database:
- Pick one representative task from your real backlog — a real query, a real migration. Not a toy.
- Give the same decision-complete task to two or three candidates — same schema, same definition of done, engine and version stated. See prompt engineering for coding agents for how to make it fair.
- Judge on your criteria: is the result correct against known data, does the query plan look sane, and did it use your dialect?
- Repeat on a second task. One is a data point; two is a signal.
Bringing your own API keys makes this cheap — swap the model, rerun the task, compare, paying only for tokens. The Vibe Father runs different models against the same job and, importantly, puts a verification gate in front of risky actions — a habit worth keeping wherever a database is involved.
Our honest bottom line for SQL
Want one model and no thinking? Opus 4.8 — careful and precise, which is exactly the temperament you want near data. Drafting routine queries at volume? DeepSeek V4 Pro or Sonnet 5. Iterating fast on drafts you'll review anyway? Gemini 3.5 Flash or Qwen3.7 Max. But the real answer isn't the model — it's the process: review destructive statements, test on a copy, guard the irreversible. Trust the board as a shortlist, then let your own schema decide. Adjacent reads: the best AI for data science, the best AI for PHP and Laravel, and the whole field in the best coding model roundup. Live numbers at /benchmarks.