Skip to content

explanation

EXPLAIN plan parser that returns plan nodes as relational rows organized as a proximity tree.

explanation · EXPLAIN plan parser that returns plan nodes as relational rows organized as a proximity tree.

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
100504explanationexplanation0.3.0STATBSD-3-ClauseSQL

PostgreSQL · 10, 11, 12, 13, 14

Relationships
Requiresplpgsql

Usage

Sources:

explanation 0.3.0 parses PostgreSQL EXPLAIN output into relational rows: one row per plan node, with child nodes referring to their parent identifiers. It is useful for SQL-side plan analysis when a proximity-tree representation is easier to query than formatted plan text.

Core Workflow

CREATE EXTENSION explanation;

SELECT *
FROM explanation('SELECT * FROM orders WHERE customer_id = 42');

Pass a single query string to explanation(text). The function runs plain EXPLAIN, parses its XML representation, and returns the plan nodes as a table for filtering, joins, or visualization.

Requirements and Caveats

The upstream release requires PostgreSQL 9.0 or later built with XML support, and its code predates modern JSON-format plan tooling. It does not run EXPLAIN ANALYZE, so the result contains planner estimates rather than measured execution. Accept query text only from trusted callers, and test the parser against the exact PostgreSQL major version because plan fields evolve between releases.

Table reader