DevTools Surf logoDevTools Surf
AI / Modern DevAnimation / CSSAPI / Config
Sign in
DevTools Surf logoDevTools Surf
AI / Modern DevAnimation / CSSAPI / Config
Sign in
HomeDatabase ToolsDatabase Indexing Analyzer

Example: Database Indexing Analyzer

A worked example, rendered from real sample data. Sign in to run the tool on your own input.

Input
CREATE TABLE users (
  id BIGINT PRIMARY KEY,
  email VARCHAR(255) NOT NULL UNIQUE,
  team_id BIGINT NOT NULL,
  status VARCHAR(16) NOT NULL,
  created_at TIMESTAMP NOT NULL
);

SELECT id, email FROM users WHERE team_id = 42 AND status = 'active' ORDER BY created_at DESC LIMIT 50;
Output
═══ What this tool did ═══
ℹ Every recommendation below comes from the SQL you pasted. This page runs offline and makes no outbound network calls. — no database was connected.
✗ Index sizes, row counts, cardinality and selectivity are NOT estimated here. Those depend on your data; the commands at the end get them from your server.
Dialect: PostgreSQL
Parsed: 1 table definition, 0 existing indexes, 1 query

═══ Schema read from your DDL ═══
─── users ───
Columns: 5
Primary key: id

═══ Recommendations from your queries (1) ═══
─── Query 1 · SELECT on users ───
  SELECT id, email FROM users WHERE team_id = 42 AND status = 'active' ORDER BY created_at DESC LIMIT 50
  CREATE INDEX idx_users_team_id_status_created_at ON users (team_id, status, created_at) INCLUDE (id, email);
• Column order: equality first (team_id, status), then the sort columns (created_at) — the equality-range-sort rule.
• The INCLUDE columns make this a covering index, so the query never touches the heap.

═══ Measure it on your server (PostgreSQL) ═══
  EXPLAIN (ANALYZE, BUFFERS, VERBOSE) <your query>;
  SELECT * FROM pg_stat_user_indexes WHERE relname = 'users';
  SELECT relname, seq_scan, idx_scan, n_live_tup FROM pg_stat_user_tables WHERE relname = 'users';
  SELECT indexrelname, idx_scan FROM pg_stat_user_indexes WHERE idx_scan = 0;   -- indexes nobody uses
  SELECT pg_size_pretty(pg_total_relation_size('users'));                 -- real size, not an estimate
  CREATE INDEX CONCURRENTLY … -- avoids the write lock on a live table
ℹ Add one index at a time and re-run EXPLAIN. Every index slows down every
…

About Database Indexing Analyzer

Database Indexing Analyzer preview - Database Tools tool

Derive CREATE INDEX recommendations from your pasted DDL and queries, with column order, redundancy and covering-index advice. Part of the DevTools Surf developer suite. Browse more tools in the Database Tools collection.

Use Cases

  • Identify missing indexes causing slow queries in a production database
  • Detect unused indexes that waste storage and slow down writes
  • Optimize composite index column ordering for multi-condition queries
  • Analyze index coverage for common query patterns before a traffic spike

Tips

  • Paste your CREATE INDEX and EXPLAIN ANALYZE output together — the analyzer compares existing indexes against the query plan to identify unused or missing indexes
  • Check the 'index selectivity' panel: high-selectivity indexes (many distinct values, like user IDs) are worth adding; low-selectivity indexes (boolean, status with 3 values) rarely help
  • Use the composite index advisor: column order in a composite index matters — the leftmost prefix rule means the index must start with the most selective equality-comparison column

Fun Facts

  • B-tree indexes, used by PostgreSQL and MySQL by default, were invented by Rudolf Bayer and Edward McCreight at Boeing in 1972. The B-tree allows O(log n) search, insert, and delete — the same complexity regardless of data size.
  • PostgreSQL's EXPLAIN ANALYZE output shows the query plan and actual execution times. The 'rows' estimate vs 'actual rows' discrepancy is the most important diagnostic signal — large discrepancies indicate stale statistics needing a VACUUM ANALYZE.
  • A properly placed index can improve query performance from O(n) (full table scan) to O(log n) — a 100,000 row table scan takes 100,000 operations; an indexed lookup takes about 17 (log2(100,000) ≈ 17). The difference is often the margin between a 0.1ms and 200ms query.

FAQ

Should I index every foreign key column?
Yes, in most cases. Foreign keys without indexes cause full table scans during JOIN operations and cascading deletes/updates. PostgreSQL automatically creates indexes on primary keys but not foreign keys — add them manually.
What is an index-only scan and when is it possible?
An index-only scan retrieves all needed data from the index itself without touching the table heap. This is only possible when the index covers all columns in the SELECT clause. Designing 'covering indexes' is a key performance optimization technique.
How do I know if my index is being used?
Run EXPLAIN (ANALYZE, BUFFERS) on the query. Look for 'Index Scan' or 'Index Only Scan' in the plan. 'Seq Scan' means the index is not being used. pg_stat_user_indexes shows index usage statistics over time for unused index identification.

Related Database Tools Tools

MongoDB Query BuilderElasticsearch Query BuilderRedis Command SimulatorCassandra CQL BuilderDynamoDB Query SimulatorFirestore Query BuilderGraph Database ExplorerSearch Relevance Scorer
New · Flagshipsimple REST client

REST Handler — Collections, env vars, history, cURL converter

Send requests, save collections (nested), swap environments, and convert between cURL / Collection JSON / REST Handler YAML.

Open

Popular tools

The most-used tools on DevToolsSurf, one click away.

Encoding & crypto

  • Base64 Encode
  • Base64 Decode
  • URL Encoder
  • URL Decoder
  • Hash Generator
  • JWT Decoder
  • JWT Encoder
  • UUID Generator
  • ULID Generator
  • Password Generator
  • Bcrypt Hash Tester

Converters

  • CSV to JSON
  • JSON to CSV
  • XML to JSON
  • JSON to XML
  • HTML → Markdown
  • HTML → React JSX
  • cURL to Code
  • Collection JSON → cURL
  • Swagger to Collection JSON
  • JSON → Go Struct
  • JSON → TypeScript Types

JSON & YAML

  • JSON Formatter
  • JSON Validator
  • JSON Viewer
  • JSON Minifier
  • JSON Diff
  • JSONPath Tester
  • YAML Formatter
  • YAML to JSON
  • JSON to YAML

Text & regex

  • Regex Tester
  • Text Diff
  • Case Converter
  • Word Counter
  • Markdown Preview
  • Slug Generator
  • Lorem Ipsum Generator
  • Markdown → PDF

CSS & color

  • CSS Beautifier
  • Minify CSS
  • Color Converter
  • Gradient Generator
  • Contrast Checker
  • Color Palette Generator
  • Flexbox Playground
  • Tailwind → CSS

Generators

  • QR Code Generator
  • Mock Data Generator
  • Favicon Generator
  • .gitignore Builder
  • README.md Generator
  • Dockerfile Generator
  • Sitemap Generator

API & networking

  • REST Handler
  • HTTP Header Analyzer
  • IP Address Lookup
  • CIDR Calculator
  • User-Agent Parser
  • HTTP Status Reference
  • OpenAPI Viewer

Date & time

  • Timestamp Converter
  • Timezone Converter
  • Cron Expression Parser
  • Duration Calculator
  • Age Calculator
  • Date Format Converter

Images

  • Image Converter
  • Image Resizer (Batch)
  • SVG Optimizer
  • Base64 ↔ Image
  • WebP ↔ AVIF Converter
  • Image Compressor

PDF tools

  • PDF Merger
  • PDF Splitter
  • PDF Compressor
  • Markdown → PDF
  • EPUB → PDF
  • MOBI / AZW → PDF
  • DOCX → PDF
  • HTML → PDF

Resources

  • Community feed
  • Themes marketplace
  • Pricing & credits
  • Privacy policy
  • Terms of service
  • Sitemap
  • robots.txt

Your account

  • Sign in
  • Dashboard
  • Run history
  • My profile
  • Settings
DevTools Surf logo
DevTools Surf919+ tools

Fast · privacy-first · client-side · © 2026

Home·Feed·ThemesPricing·Sign inPrivacy·Sitemap Feedback