Stop Reading Raw EXPLAIN Output! PEV2 Transforms PostgreSQL↗ Bright Coding Blog Plans Instantly
You've been there. Staring at a wall of text that looks like someone dumped a parser error into your terminal. Aggregate (cost=12.50..12.51 rows=1 width=8) -> Seq Scan on employees (cost=0.00..10.00 rows=1000 width=0). Your eyes glaze over. You squint. You scroll. You wonder if that nested loop is actually killing your query or if you're misreading the indentation.
Here's the brutal truth: Raw PostgreSQL EXPLAIN output is a productivity killer. It's 2024, and we're still debugging million-dollar database performance issues by parsing ASCII art with our human brains. Meanwhile, every other tool in our stack got beautiful, interactive visualizations years ago. Why are we settling for stone-age query analysis?
What if you could transform that cryptic text into a stunning, interactive diagram in seconds? What if you could spot bottlenecks at a glance, share insights with your team instantly, and finally understand what PostgreSQL is actually doing under the hood?
Enter PEV2 — the Postgres Explain Visualizer 2 that developers are quietly adopting to 10x their query optimization workflow. Built by Dalibo as a modern Vue.js↗ Bright Coding Blog component, PEV2 doesn't just pretty-print your plans. It exposes the hidden performance stories locked inside your execution plans. And the best part? You can be up and running in under 60 seconds, with zero infrastructure headaches.
Ready to stop guessing and start seeing? Let's dive into why PEV2 is becoming the secret weapon for PostgreSQL performance engineers worldwide.
What is PEV2? The PostgreSQL Visualizer Developers Actually Want
PEV2 (Postgres Explain Visualizer 2) is a modern, open-source Vue.js component that transforms raw PostgreSQL EXPLAIN output into rich, interactive visual diagrams. Born from the ashes of the original Postgres Explain Visualizer (pev) by Alex Tatiyants, PEV2 represents a complete ground-up rewrite that addresses the abandonment of its predecessor — no commits for over three years, stalled pull requests, and growing incompatibilities with modern toolchains.
The team at Dalibo, a French PostgreSQL consultancy with deep expertise in database optimization, recognized this gap and rebuilt the experience from scratch. Their mission? Give the PostgreSQL community a visualization tool that matches the sophistication of the database itself.
But PEV2 isn't just a prettier face on old functionality. It's architected as a reusable Vue 3 component, meaning it can drop into existing applications, dashboards, and internal tools with minimal friction. Whether you're building a DBA cockpit, a query monitoring platform, or just need to share plans with stakeholders who don't speak EXPLAIN ANALYZE, PEV2 adapts to your workflow — not the other way around.
The project is actively maintained, leverages modern web standards, and offers three distinct deployment modes that we'll explore in depth. In an ecosystem where query optimization remains one of the highest-leverage skills a developer can possess, PEV2 removes the friction that prevents teams from actually doing it consistently.
Key Features That Make PEV2 Insanely Powerful
What separates PEV2 from throwing your EXPLAIN output into a generic graph tool? Let's break down the technical capabilities that make this a genuine performance analysis platform:
-
Interactive Hierarchical Visualization: PEV2 renders execution plans as intuitive tree diagrams where you can expand, collapse, and inspect nodes. The visual hierarchy mirrors PostgreSQL's actual execution order, making it trivial to trace data flow from scan operations through joins, sorts, and aggregates.
-
Vue 3 Native Architecture: Built as a first-class Vue 3 component, PEV2 leverages the composition API, reactive state management, and modern rendering optimizations. This isn't a jQuery plugin wrapped in duct tape — it's designed for contemporary frontend stacks.
-
Zero-Dependency Standalone Mode: The all-in-one
pev2.htmlfile contains everything needed to run locally. Nonpm install. No build pipeline. No network requests to external services. This is gold for air-gapped environments, security-conscious organizations, or quick debugging sessions on production bastion hosts. -
Dual Integration Paths: Whether you're dropping a script tag into a legacy dashboard or importing ES modules into a Vite-powered SPA, PEV2 meets you where you are. The component API is clean and predictable across both patterns.
-
Bootstrap 5 Styling Foundation: Consistent, professional UI out of the box that integrates cleanly with existing design systems. The CSS is scoped and overridable for custom branding.
-
Plan + Query Correlation: PEV2 accepts both the execution plan and the original query, enabling side-by-side analysis that connects abstract operations back to concrete SQL structures.
-
Shareable via Dalibo's Hosted Service: For teams that need frictionless collaboration, explain.dalibo.com provides instant sharing without managing infrastructure.
Real-World Use Cases Where PEV2 Shines
Theory is nice, but where does PEV2 actually save your bacon? Here are four battle-tested scenarios:
1. Production Incident Response at 3 AM
Your PagerDuty screams. Latency p99 just spiked 400%. You pull the slow query log, grab the EXPLAIN ANALYZE output, and paste it into PEV2. Within seconds, that suspicious bitmap heap scan glows red-hot in the visualization. You spot the missing index that the text output buried under 47 lines of nested loop details. Mean time to resolution: slashed.
2. Code Review for Query Performance
Your junior developer submitted a "simple" reporting query. The EXPLAIN output looks innocent enough — until PEV2 reveals a hidden sequential scan on a 200-million-row table triggered by an implicit type conversion. The visual makes the problem obvious to everyone in the review, not just the senior DBA who can parse raw plans in their sleep.
3. Client Communication and Documentation
You need to justify a schema redesign to non-technical stakeholders. Raw EXPLAIN output makes their eyes cross. A PEV2 diagram showing the current plan's convoluted join tree versus the proposed index strategy's clean traversal? That's a conversation everyone can participate in. Export the visualization, annotate it, and build consensus faster.
4. Embedded in Internal Observability Platforms
Your platform team is building a query performance dashboard. Rather than reinventing visualization logic, import PEV2 as a component. Now every slow query alert links directly to an interactive plan explorer. Your developers self-serve optimization without escalating to the database team for every investigation.
Step-by-Step Installation & Setup Guide
PEV2's flexibility is its superpower. Choose your adventure:
Option 1: Zero-Setup Local Usage (Recommended for Quick Debugging)
Perfect for one-off investigations, production environments with restricted internet access, or when you just need results now.
# Download the standalone HTML file
curl -L -o pev2.html https://www.github.com/dalibo/pev2/releases/latest/download/pev2.html
# Open in your browser — that's it
open pev2.html # macOS
xdg-open pev2.html # Linux
start pev2.html # Windows
No server required. No dependencies. The file is completely self-contained with all JavaScript↗ Bright Coding Blog, CSS, and Vue runtime bundled inline.
Option 2: Dalibo's Hosted Service (Best for Sharing)
Navigate to explain.dalibo.com, paste your EXPLAIN output, and receive a shareable URL. Ideal for Slack threads, support tickets, or asynchronous team collaboration.
Option 3: Script Tag Integration (No Build Tools)
Drop this into any HTML page where you need plan visualization:
<!-- Load Vue 3 runtime from CDN -->
<script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script>
<!-- Load PEV2 component distribution -->
<script src="https://unpkg.com/pev2/dist/pev2.umd.js"></script>
<!-- Bootstrap 5 CSS is required for PEV2 styling -->
<link
href="https://unpkg.com/bootstrap@5/dist/css/bootstrap.min.css"
rel="stylesheet"
/>
<link rel="stylesheet" href="https://unpkg.com/pev2/dist/pev2.css" />
<!-- Mount point for the visualization -->
<div id="app" class="d-flex flex-column vh-100">
<pev2 :plan-source="plan" plan-query="" />
</div>
<script>
// Destructure Vue's createApp from global build
const { createApp } = Vue
// Your raw PostgreSQL EXPLAIN output
const plan = `
Aggregate (cost=12.50..12.51 rows=1 width=8)
-> Seq Scan on employees (cost=0.00..10.00 rows=1000 width=0)
`;
// Create Vue application with reactive plan data
const app = createApp({
data() {
return {
plan: plan, // Expose plan to template
}
},
})
// Register PEV2 component globally
app.component("pev2", pev2.Plan)
// Mount to DOM element
app.mount("#app")
</script>
Critical configuration notes:
- The
plan-sourceprop accepts the raw EXPLAIN string plan-queryoptionally accepts the original SQL for correlation display- Bootstrap 5 CSS is mandatory — PEV2's styling depends on Bootstrap's utility classes and component styles
- The container uses
vh-100to ensure full viewport height for the visualization
Option 4: Modern Build Tool Integration (npm/Vite/Webpack)
For production applications with existing build pipelines:
# Install from npm registry
npm install pev2
Then in your component:
// Import the Plan component and required styles
import { Plan } from "pev2"
import "pev2/dist/pev2.css"
export default {
name: "PEV2 example",
components: {
// Register with custom element name
pev2: Plan,
},
data() {
return {
plan: plan, // Your EXPLAIN output string
query: query, // Original SQL query (optional)
}
},
}
Template usage:
<div id="app">
<!-- Bind both plan and query for full analysis -->
<pev2 :plan-source="plan" :plan-query="query"></pev2>
</div>
Don't forget Bootstrap CSS — add to your HTML head or import via your bundler:
<link
href="https://unpkg.com/bootstrap@5/dist/css/bootstrap.min.css"
rel="stylesheet"
/>
REAL Code Examples: PEV2 in Action
Let's dissect actual implementation patterns from the PEV2 repository, with detailed commentary on what each section accomplishes:
Example 1: Minimal Vanilla HTML Integration
This is the fastest path to visualization — copy, paste, and point at your plan:
<script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script>
<script src="https://unpkg.com/pev2/dist/pev2.umd.js"></script>
<link
href="https://unpkg.com/bootstrap@5/dist/css/bootstrap.min.css"
rel="stylesheet"
/>
<link rel="stylesheet" href="https://unpkg.com/pev2/dist/pev2.css" />
<div id="app" class="d-flex flex-column vh-100">
<pev2 :plan-source="plan" plan-query="" />
</div>
<script>
const { createApp } = Vue
const plan = `
Aggregate (cost=12.50..12.51 rows=1 width=8)
-> Seq Scan on employees (cost=0.00..10.00 rows=1000 width=0)
`;
const app = createApp({
data() {
return {
plan: plan,
}
},
})
app.component("pev2", pev2.Plan)
app.mount("#app")
</script>
What's happening here? The UMD build exposes pev2 as a global object. We destructure createApp from Vue's global build, define our plan as a template literal (preserving PostgreSQL's indentation), and register the component before mounting. The vh-100 class ensures the visualization fills the viewport — critical for large, complex plans that need scrolling space.
Example 2: ES Module Import with Full Props
For modern bundlers, this pattern provides tree-shaking compatibility and cleaner dependency management:
import { Plan } from "pev2"
import "pev2/dist/pev2.css"
export default {
name: "PEV2 example",
components: {
pev2: Plan,
},
data() {
return {
plan: plan,
query: query,
}
},
}
Key insight: Named imports allow bundlers to eliminate dead code. The CSS import is side-effect only — it registers PEV2's component styles without exporting values. By binding both plan-source and plan-query, you enable PEV2's most powerful feature: correlating visual plan nodes with specific SQL clauses.
Example 3: Template Integration Pattern
<div id="app">
<pev2 :plan-source="plan" :plan-query="query"></pev2>
</div>
The colon prefixes (:) are Vue shorthand for v-bind, creating reactive one-way data flow. When your plan data updates — say, from a file upload or API response — the visualization automatically re-renders. This reactivity is crucial for building interactive tools where users can compare multiple plans side-by-side.
Example 4: Bootstrap CSS Requirement
<link
href="https://unpkg.com/bootstrap@5/dist/css/bootstrap.min.css"
rel="stylesheet"
/>
This isn't optional styling — PEV2's internal components rely on Bootstrap's grid system, spacing utilities, and component classes. Without it, you'll see unstyled, broken layouts. For custom theming, load Bootstrap first, then override with your own CSS using higher specificity or CSS custom properties.
Advanced Usage & Best Practices
Ready to go beyond basic integration? Here's how performance engineers squeeze maximum value from PEV2:
Use EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) for richest visualization. PEV2 parses extended output beautifully, and the JSON format eliminates parsing ambiguities that sometimes trip up text-based analysis.
Implement plan versioning by storing historical EXPLAIN outputs. Diff visualizations across schema changes, index additions, or query rewrites. The visual delta tells a story that raw numbers obscure.
Build a plan repository in your observability stack. When PEV2 is embedded, tag plans with deployment versions, query hashes, and execution timestamps. Suddenly you have searchable, visual query performance history.
Pre-filter sensitive data before sharing via explain.dalibo.com. PEV2 visualizes what you give it — scrub literals, table names, or proprietary schema details based on your security posture.
Combine with auto_explain for zero-friction capture. PostgreSQL's auto_explain module logs slow query plans automatically. Feed those directly into PEV2 for proactive optimization without manual EXPLAIN execution.
PEV2 vs. Alternatives: The Honest Breakdown
| Feature | PEV2 | Original PEV | pgAdmin | Raw Terminal |
|---|---|---|---|---|
| Active Maintenance | ✅ Dalibo team | ❌ 3+ years stale | ✅ | N/A |
| Vue 3 / Modern JS | ✅ Native | ❌ jQuery era | ⚠️ Tk/Tcl | N/A |
| Embeddable Component | ✅ Drop-in | ❌ Standalone only | ❌ | N/A |
| Zero-Install Option | ✅ Single HTML file | ❌ | ❌ | ✅ |
| Interactive Sharing | ✅ explain.dalibo.com | ❌ | ⚠️ Limited | ❌ |
| Open Source | ✅ MIT | ✅ | ✅ | ✅ |
| Plan + Query Correlation | ✅ | ⚠️ Basic | ⚠️ Basic | ❌ |
The verdict? PEV2 wins on modern architecture, flexibility, and active evolution. pgAdmin's visualizer works but locks you into their ecosystem. The original PEV pioneered the space but is effectively frozen in time. Raw terminal output? That's not a competitor — that's the problem.
FAQ: Your PEV2 Questions Answered
Does PEV2 work with PostgreSQL 15 and 16?
Yes. PEV2 parses standard EXPLAIN output formats that have remained consistent across PostgreSQL versions. New plan node types are gracefully handled.
Can I use PEV2 with React↗ Bright Coding Blog or other frameworks?
PEV2 is a Vue component, but you can wrap it in a Vue-custom-element or use it in an iframe. Native React/Angular ports aren't available, but the standalone HTML mode works everywhere.
Is my query data sent to Dalibo's servers?
Only if you use explain.dalibo.com. The standalone HTML file and self-hosted integrations process everything locally in your browser.
Does PEV2 support EXPLAIN ANALYZE output?
Absolutely. In fact, ANALYZE output with actual timing and row counts produces the most informative visualizations. Add BUFFERS and FORMAT JSON for maximum detail.
Can I customize the color scheme or styling?
PEV2 uses Bootstrap 5 classes extensively, so standard Bootstrap theming approaches work. Override CSS custom properties or load a custom Bootstrap build for branded integrations.
What about very large execution plans?
PEV2 handles complex plans with hundreds of nodes. The interactive collapse/expand functionality keeps navigation manageable. For extreme cases, the zoom and pan controls maintain usability.
Is commercial support available?
Dalibo offers PostgreSQL consulting services. For PEV2-specific enterprise needs, reach out through their GitHub repository or official channels.
Conclusion: See Your Queries, Fix Your Performance
Raw PostgreSQL EXPLAIN output is a relic from an era when we accepted friction as the price of power. PEV2 demolishes that tradeoff. With three deployment modes spanning from zero-install HTML files to sophisticated component integration, it adapts to your constraints rather than imposing new ones.
The visualization isn't cosmetic fluff — it's cognitive leverage. When you see the sequential scan glowing hot red, when you watch the nested loop explode across the diagram, you understand instantly what hours of text parsing might never reveal. That speed of comprehension translates directly to faster optimizations, happier users, and infrastructure costs that don't spiral out of control.
The PostgreSQL community deserves tools that match the database's excellence. PEV2 delivers. Whether you're firefighting production incidents, reviewing code, or building the next generation of database observability, this is the visualization layer you've been missing.
Stop squinting at text. Start seeing your data flow.
👉 Get PEV2 on GitHub — star the repo, try the live demo, or grab the standalone file right now. Your future self — debugging that 3 AM performance issue with a clear visual — will thank you.