Start a project

Tool 129 of 194 · Data

SQL Query Linter

Catch the SQL patterns that make queries slow, wrong or dangerous before they reach production.

SQL Query Linter

SQL

Findings

LineRuleFoundWhy it matters and what to do

Rules

Turn rules on or off

By rule

Works on any dialect without a schema, so it reads the SQL's structure rather than your tables: it can't see indexes or row counts. The rules were checked against the same checks written on sqlglot's parse tree, on over 600 queries.

01

What it does

Checks SQL queries for 23 anti-patterns that make them slow, wrong or risky, from SELECT * and implicit joins to non-sargable filters and NULL traps.

  • Non-sargable filters: functions and arithmetic on indexed columns, leading-wildcard LIKE
  • Wrong results: = NULL, NOT IN with a subquery, LIMIT without ORDER BY, columns missing from GROUP BY
  • Risky changes: UPDATE or DELETE with no WHERE, INSERT with no column list, dynamic SQL
  • Join problems: comma joins, joins without ON, cross joins, DISTINCT hiding a bad join

02

Private by design

Everything happens in your browser. Nothing you type, paste or upload is sent anywhere, and it keeps working offline once the page has loaded.

03

What you get

Findings with line numbers, reasons and fixes, by rule, with a Copy and a Download button on every result.

  • SQL
  • Databases
  • Performance

Why it matters

Most slow or wrong queries fail in familiar ways. A function around a column in WHERE stops the index being used. NOT IN against a subquery quietly returns nothing when the subquery contains a NULL. = NULL is never true. An UPDATE without WHERE changes every row. None of these are syntax errors, so the database runs them without complaint.

This linter reads the structure of your SQL, statement by statement and subquery by subquery, and flags 23 of these patterns with the line, the reason and the usual fix. It doesn't need your schema, so it works with any database. The rules were checked against an independent implementation on sqlglot's parse tree.

How to use it

  1. Paste one or more SQL statements.
  2. Read the findings, worst first in the summary.
  3. Switch off rules that don't apply to you.
  4. Fix and paste again.

FAQ

What does non-sargable mean?

A condition the database can't answer with an index seek, usually because the column is inside a function or a calculation.

Why is NOT IN with a subquery risky?

If the subquery returns any NULL, x NOT IN (…) is never true, so the query returns no rows. NOT EXISTS doesn't have that problem.

Is SELECT * always bad?

It's fine for quick exploration. In application code it fetches columns you don't use and breaks when the table changes.

Does it know my indexes?

No. It works from the SQL alone. Use EXPLAIN to see what the database actually does.

Work with me

Want a site that gets these right?

I build fast, accessible websites and web apps that pass these checks from day one. Tell me about your project and I'll reply personally with honest next steps.

All developer tools · Back to leej.uk