Explore and visualize how PostgreSQL chooses query plans for your SQL – all in your browser.
Plan Explorer is a web application for visualizing the different query plans that PostgreSQL generates for a particular query across multi-dimensional parameter spaces.
The tool allows users to explore how PostgreSQL's query planner chooses different execution plans based on query parameters and cost settings—that is, it shows when PostgreSQL selects a different plan due to changing parameters.
All of this runs entirely in the browser, without requiring a separate database server. Plan Explorer is inspired by the Picasso database query optimizer visualizer, which implements similar ideas and functions.
Note
This project is a research prototype and is purely vibe coded to explore how research tools can be generated with little effort these days. So, it may not always have the most understandable or conventionally structured source code.
- Flexible Search Space: Define one- or two-dimensional parameter spaces (e.g., predicate selectivity, cost parameters) to iterate over.
- Custom SQL Queries: Input your own SQL queries with placeholders for dynamic parameters.
- Plan Fingerprinting: Automatically groups and colors similar query plans for easy visualization.
- No Backend Required (In-Browser Mode): All computation and visualization happen client-side. Uses PGlite, a WebAssembly build of PostgreSQL, to run queries and generate plans directly in your browser. This mode is fully standalone and requires no server or backend—everything runs locally in your browser.
- Optional Proxy Mode: For advanced use cases, you can connect Plan Explorer to a real PostgreSQL database server via a lightweight Node.js proxy. This enables working with large datasets or features not supported by PGlite. See the section "Modes of Operation" below for details.
- Visualize when PostgreSQL switches from a table scan to an index scan as selectivity or cost parameters change.
- Explore the impact of
random_page_cost
and other planner settings on query plan selection. - Analyze complex queries, such as self-joins, and observe how the planner chooses among multiple strategies.
- Define Search Space: Set up to two dimensions (ranges and steps) for the parameters you want to explore.
- Database Setup: Enter SQL statements to prepare your database (e.g., create tables, insert data).
- Query Input: Write your SQL query using placeholders (
%%DIMENSION0%%
,%%DIMENSION1%%
) for dynamic parameters. - Run: Execute the analysis and view the resulting plan visualization.
Plan Explorer can be used in two modes:
- In-Browser Mode (default): All query execution and plan analysis happen directly in your browser using PGlite, a WebAssembly build of PostgreSQL. No backend or server setup is required.
- Proxy Mode (dev:full): The application connects to a real PostgreSQL database server via a lightweight Node.js proxy. This mode is useful for working with large datasets or features not supported by PGlite. Credentials for the database connection are read from a
.env
file (see below).
flowchart LR
subgraph **Browser**
UI["WebUI"]
PGLite["PGlite (WebAssembly PostgreSQL)"]
UI -- "SQL, Parameters" --> PGLite
PGLite -- "Query Results, Plans" --> UI
end
subgraph "**Proxy Mode** (Optional)"
Proxy["Proxy Server"]
PG["PostgreSQL Database"]
UI -- "HTTP (SQL/Params)" --> Proxy
Proxy -- "SQL" --> PG
PG -- "Results" --> Proxy
Proxy -- "Results" --> UI
end
- In-Browser Mode: All arrows stay within the "Browser" box. No backend or network required.
- Proxy Mode: The browser app communicates with the proxy server, which forwards queries to a real PostgreSQL database and returns results.
- Clone the repository:
git clone https://github.com/jnidzwetzki/planexplorer.git cd planexplorer
- Install dependencies:
npm install # or yarn install
- Start the development server:
npm run dev # or yarn dev
- Open your browser: Visit http://localhost:3000/planexplorer to use the app.
npm run build
npm start
In addition to running fully in the browser, Plan Explorer supports connecting to a real PostgreSQL database server when running in dev:full
mode. In this mode, the application reads database connection credentials from a .env
file in the project root.
- Create a
.env
file in the project root (or copy the provided.env.example
):cp .env.example .env
- Edit the
.env
file and set your database credentials:PGHOST=localhost PGPORT=5432 PGUSER=your_db_user PGPASSWORD=your_db_password PGDATABASE=your_db_name
- Start the app in full server mode:
npm run dev:full # or yarn dev:full
When running in this mode, queries and plan analysis are executed against the configured PostgreSQL server instead of the in-browser database.
To see the tool in action, visit the live demo: https://jnidzwetzki.github.io/planexplorer/
This project is open source. See LICENSE for details.
- Inspired by Picasso: The Database Query Optimizer Visualizer
- Built with the help of GitHub Copilot and VS Code agent mode