querydoctor
v0.1.7
Published
Local CLI to diagnose PostgreSQL query performance and validate fixes with HypoPG.
Maintainers
Readme
QueryDoctor
QueryDoctor is a local-first CLI that diagnoses slow PostgreSQL queries and validates potential index fixes using HypoPG before applying anything to production.
What it does
For the top slow statements in pg_stat_statements, QueryDoctor:
- Sanitizes parameterized SQL
- Runs
EXPLAIN (FORMAT JSON) - Detects likely root causes (seq scans, wildcard LIKE, sorts)
- Simulates an index with HypoPG
- Compares planner cost before/after
- Prints recommended SQL + confidence
Requirements
- Node.js 18+
- PostgreSQL with:
pg_stat_statementshypopg
DATABASE_URLset in your environment
Install
npm installRun
DATABASE_URL=postgres://user:pass@localhost:5432/dbname npm startOr after linking globally:
npm link
querydoctorSafety
- QueryDoctor does not create real indexes.
- It only creates hypothetical indexes (
hypopg_create_index) and resets them (hypopg_reset). - It performs read-only diagnosis queries and EXPLAIN plans.
