# First release of pg\_stat\_plans

DevFeed: [First release of pg\_stat\_plans](<https://devfeed.tech/articles/first-release-of-pg-stat-plans-33645.md>)

Original publisher: [Read original article](<https://pgeoghegan.blogspot.com/2012/10/first-release-of-pgstatplans.html>)

Author: Peter Geoghegan (noreply@blogger.com)

Published: 2012-10-20T14:53:00Z

Content type: release

Language: en

Sources: [Peter Geoghegan's blog](<https://devfeed.tech/sources/peter-geoghegan-s-blog.md>)

Topics: [PostgreSQL](<https://devfeed.tech/topics/postgresql.md>), [Databases](<https://devfeed.tech/topics/databases.md>), [SQL](<https://devfeed.tech/topics/sql.md>), [Open Source](<https://devfeed.tech/topics/open-source.md>), [Logging](<https://devfeed.tech/topics/logging.md>)

Tags: [database](<https://devfeed.tech/tags/database.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [performance](<https://devfeed.tech/tags/performance.md>), [pg-stat-plans](<https://devfeed.tech/tags/pg-stat-plans.md>), [pg-stat-statements](<https://devfeed.tech/tags/pg-stat-statements.md>), [planner](<https://devfeed.tech/tags/planner.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [query](<https://devfeed.tech/tags/query.md>), [release](<https://devfeed.tech/tags/release.md>), [sql](<https://devfeed.tech/tags/sql.md>)

## AI overview

The article announces the first release of pg_stat_plans, an open-source PostgreSQL module based on pg_stat_statements. It analyzes plan execution costs and planner regressions, extends normalized-statement analysis to PostgreSQL 9.0 and 9.1, and tracks plan costs over time.

## Source excerpt

Anyone who attended my recent talk at Postgres Open, which was co-presented with my 2ndQuadrant colleague Greg Smith, "Beyond Query Logging", will be aware that pg_stat_statements, the standard contrib module that assigns execution costs to queries and makes them available from a view in the database, has been improved considerably in the recent 9.2 Postgres release. It has been improved in a way that we believe will alter the preferred approach to workload analysis on PostgreSQL databases away from log analysis tools, which just don't offer the performance, flexibility or granularity of this new approach. We also announced a new open source tool that addresses a related but slightly different problem (the analysis of plan execution costs, and planner regressions), as well as making most of the benefits of pg_stat_statements on 9.2 available to users stuck on earlier versions of Postgres. This new tool is called pg_stat_plans, and is itself based on pg_stat_statements. The 9.2 pg_stat_statements feature of particular importance, the ability to "normalise" non-prepared statements that the large majority of applications use exclusively is now brought to earlier versions (versions 9.0 and 9.1, though pg_stat_plans works fine on 9.2 too). Since pg_stat_plans fingerprints plans rather than query trees, the way this works is slightly different to pg_stat_statements, and perhaps doesn't quite match people's intuitive expectations about how normalisation ought to behave in some cases. These differences have been extensively documented. pg_stat_plans also has the ability to EXPLAIN a stored, representative SQL text, in order to facilitate deeper analysis of plan execution costs. Plan total_cost and startup_cost is tracked over time for each plan, for example, so that the "crossover point" at which the planner begins to prefer an alternative plan can sometimes be observed, and the planner's "reasoning" can perhaps be better understood. pg_stat_plans is distributed under the P