SC-022 · Developer Utilities

QueryLens

Plain-language explanations of MySQL and PostgreSQL query plans, with index ideas

QueryLens is planned to read EXPLAIN output from MySQL and PostgreSQL, describe in plain language where a query spends its time, and suggest indexes or rewrites worth testing.

  1. 01Concept
  2. 02Planned
  3. 03In Development
  4. 04Beta
  5. 05Live

This product is not yet available. The documentation below describes the planned product and may change as we build it.

01Purpose

Query plans hold the answer to most slow-query questions, but they are written for database engines rather than for the people who wrote the query. A PostgreSQL plan is a nested tree of nodes with estimated and actual row counts; MySQL output is a table or JSON document of access types and key usage. Many developers run EXPLAIN, see a wall of output, and fall back to guessing which index to add.

QueryLens is designed to translate. Paste a query with its plan, and QueryLens will identify the most expensive steps, describe them in ordinary sentences, and point out common causes such as a sequential scan on a large table, a sort that spills to disk, or a row estimate far from reality. Where a pattern suggests one, it will propose a candidate index or rewrite along with its reasoning, so a developer can test the idea rather than accept it blindly.

02Who it is for

  • Application developers — understand why an ORM-generated query is slow without becoming a database specialist.
  • Backend engineers — check new queries before they reach production.
  • Database administrators — share clear explanations with developers instead of annotating plans by hand.
  • Code reviewers — attach a readable plan summary to a pull request that changes a query.
  • Support engineers — triage reported slowness on self-hosted installations.

03Planned features

  • Plan parsing — Accepts PostgreSQL text and JSON plans, including EXPLAIN ANALYZE output, and MySQL tabular, JSON and tree formats.
  • Cost hotspots — Ranks plan nodes by their share of estimated cost or measured time, so the first thing you read is the step that matters most.
  • Plain-language narration — Describes each significant step, such as a nested loop over a large outer input, in one or two sentences.
  • Estimate checks — When actual row counts are present, flags nodes where estimated and actual rows differ sharply, a common sign of stale statistics.
  • Index suggestions — Proposes candidate indexes from filter, join and sort columns, with the column order explained.
  • Rewrite hints — Flags patterns such as functions wrapped around indexed columns, leading wildcards or correlated subqueries, with alternative formulations.
  • Plan comparison — Compare plans before and after a change to confirm a new index is used and the hotspot has moved.

04Use cases

A slow dashboard query

A developer pastes a PostgreSQL EXPLAIN ANALYZE result for a dashboard query. QueryLens ranks a sequential scan on the events table as the main cost, notes the filter on account and created date, and suggests a composite index with the equality column first. The developer tests it in staging and uses plan comparison to confirm the change.

An ORM query in review

A pull request adds a query generated by an ORM. The reviewer runs MySQL EXPLAIN and sees a filesort on a large result. QueryLens explains that the ORDER BY column is not covered by the index used for filtering, and the discussion moves from guesswork to a specific change.

Stale statistics

A query that was fast last month is now slow. QueryLens flags a join where the planner expected a few hundred rows but processed vastly more, and suggests refreshing table statistics before adding any new index.

05How it is intended to work

  1. Choose the engine — Select MySQL or PostgreSQL and the version family.
  2. Paste the query and plan — Include EXPLAIN ANALYZE output wherever it is safe to run.
  3. Add schema context — Optionally paste table definitions and existing indexes for more accurate suggestions.
  4. Read the summary — Start with the ranked hotspots and their explanations.
  5. Test suggestions — Apply a candidate index or rewrite in a non-production environment.
  6. Compare plans — Paste the new plan to confirm the improvement.

06Technical overview

Planned architecture

Engine-specific parsers convert each plan format into a common node model with operation type, estimated rows, actual rows, cost and timing where available. A rules layer then evaluates known patterns against that model and any supplied schema context. A language model is planned to turn rule findings into readable narration, constrained to the facts the rules produced, so explanations stay tied to the actual plan rather than general advice.

Data and integrations

  • Inputs: pasted plans, queries and table definitions. No live database connection is required.
  • A possible read-only connector could run EXPLAIN against a non-production database on request.
  • Planned export of the summary as Markdown for pull requests and tickets.

Security and privacy

  • Queries and plans can reveal table names and literal values, so QueryLens is designed to offer literal masking before analysis.
  • Pasted content is not retained after a session unless the user saves it.
  • Any future database connector would be designed for read-only credentials and non-production use.

07Documentation

Getting started (planned)

Use EXPLAIN ANALYZE output when you can, run against data similar in size to production. Plans with estimates alone lead to weaker suggestions.

Key concepts

  • Plan node — One step in the query plan, such as a scan, join or sort.
  • Hotspot — A node responsible for a large share of cost or time.
  • Estimate gap — The difference between the rows the planner expected and the rows actually processed.
  • Candidate index — A suggested index to test, not a guaranteed improvement.

Limitations and considerations

  • Suggestions are starting points. Every index carries write and storage costs that QueryLens cannot fully weigh.
  • Without schema context, a suggestion may duplicate an index that already exists.
  • EXPLAIN ANALYZE executes the query, so avoid running it in production for statements that modify data.
  • Only MySQL and PostgreSQL are in the initial plan.

08Roadmap

  1. Phase 1Planned

    Plan parsers and node model

    Parsing for PostgreSQL and MySQL plan formats into one common representation.

  2. Phase 2Planned

    Hotspots and narration

    Cost ranking, estimate-gap detection and plain-language step descriptions.

  3. Phase 3Planned

    Index and rewrite suggestions

    Rule-based candidate indexes and rewrite hints using optional schema context.

  4. Phase 4Planned

    Plan comparison and connector

    Before-and-after comparison and a possible read-only connector for non-production databases.

09Questions

Can I use QueryLens today?

No. QueryLens is a planned product and has not been released. The capabilities described here are intended, not available.

Does QueryLens need access to my database?

No. The planned workflow works from pasted plans and table definitions. A read-only connector for non-production databases is a possible later addition.

Should I apply its index suggestions directly?

No. Suggestions are candidates to test in a non-production environment, since every index affects write performance and storage.

Will other databases be supported?

The initial plan covers MySQL and PostgreSQL. Other engines may be considered later.