Online SQL Anti-Pattern & ESR Composite Index Generator

Paste any slow SELECT query to catch index-breaking anti-patterns and generate optimal PostgreSQL & MySQL composite index DDL using the Equality → Sort → Range (ESR) rule.

100% Browser-Local Zero Data Uploaded Instant Export

SQL Query to Analyze

Detected Anti-Patterns

Recommended ESR Composite Indexes

JetBrains Plugin — SQL Explain Lens

Inspect Live EXPLAIN ANALYZE Plans Inside DataGrip & IntelliJ with SQL Explain Lens

Go beyond static query linting: visualize actual row estimates, seq-scan hotspots, and index recommendations right inside your JetBrains IDE.

Get SQL Explain Lens →

Frequently Asked Questions

What is the ESR rule for composite SQL indexes?

ESR stands for Equality, Sort, Range: place columns filtered with '=' or 'IN' first, followed by 'ORDER BY' sort columns, and finally range columns ('>', '<', 'BETWEEN') so the database avoids expensive in-memory filesorts.

Why does wrapping a column in LOWER() or YEAR() break B-Tree indexes?

Applying a function to an indexed column makes the predicate non-SARGable, forcing a full table scan unless you create a matching functional/expression index or rewrite the filter as a range.

Why does the PostgreSQL output use CREATE INDEX CONCURRENTLY?

CONCURRENTLY builds the index without locking out writes on production tables, avoiding downtime during migrations.

Related Developer Tools