Database & SQL • Pretty + CREATE INDEX

SQL Formatter & Static Index Advisor

Format dense one-line SQL queries with clean uppercase keywords and indentation while getting static index DDL suggestions for WHERE, JOIN, and ORDER BY predicates.

Input & Options Local JS Execution
Works with PostgreSQL, MySQL, SQLite, and standard ANSI SELECT/JOIN/WHERE queries.
Parsed Output & Diagnostics Ready
Status
...

Composite B-Tree Index Column Order Rule

SQL Clause TypePosition in Composite IndexReason
Equality (=, IN)First columnsNarrows B-tree immediately to contiguous equality bucket
Range (>, >=, <, BETWEEN)After equality columnsSubsequent B-tree columns lose sort efficiency after a range scan
ORDER BY / LIMITMatch prefix + sort directionAvoids explicit in-memory/disk Sort node
LIKE '%suffix'Requires GIN pg_trgm indexStandard B-tree cannot use leading-wildcard patterns

Parser Methodology & Privacy Guarantees

Formats SQL clauses using keyword line-breaks while preserving string literals, extracts table aliases, inspects WHERE/JOIN/ORDER BY columns for equality-then-range composite index ordering, and audits anti-patterns.

  • Uppercases standard SQL clauses while preserving quoted string literals intact.
  • Detects `SELECT *`, leading-wildcard `LIKE '%...'`, and non-sargable function-wrapped columns like `LOWER(col)`.
  • Suggests `CREATE INDEX CONCURRENTLY` DDL statements prioritized by equality then range/sort selectivity.

Scope & limitations: Static analysis does not inspect live table cardinalities; confirm final index usage with PostgreSQL EXPLAIN ANALYZE.

Frequently Asked Questions

Why does column order matter in a composite B-tree index?
Place equality filters (=) before range comparisons (>=, <, BETWEEN). Putting a range column first prevents B-tree pruning on subsequent columns.
Why is LIKE '%term' flagged as non-sargable?
A standard B-tree sorts strings left-to-right, so leading % prevents index seek. Use PostgreSQL pg_trgm GIN indexes or reversed/full-text tsvector indexes instead.
Are SQL string literals modified when uppercasing keywords?
No. Single- and double-quoted literals remain byte-for-byte untouched during formatting.

Related Developer Parsers

Every parser on DevParse runs 100% inside your browser with zero backend telemetry, zero file uploads, and zero cookie banners. Support development via Fourthwall or sponsor a clean developer slot.