A collection of PostgreSQL scripts for database analysis, bloat estimation, index optimization, and idle transaction management.
pgx_scripts is a collection of SQL scripts created by PostgreSQL Experts for database analysis and administration. It provides tools to estimate table and index bloat, manage idle transactions, analyze index usage, and monitor locks. These scripts help administrators optimize PostgreSQL performance and maintain database health.
PostgreSQL database administrators and developers who need to monitor, analyze, and optimize database performance, particularly in production environments.
Developers choose pgx_scripts because they are expert-curated, practical tools that address specific PostgreSQL administration challenges like bloat estimation and idle transaction cleanup, offering reliable solutions without requiring external dependencies.
A collection of useful little scripts for database analysis and administration, created by our team at PostgreSQL Experts.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The bloat estimation scripts are overhauled versions based on queries from PostgreSQL experts, providing accurate estimates for common storage waste in tables and BTree indexes.
Includes version-specific stored procedures (e.g., kill_idle_93.sql for PostgreSQL 9.2+ with JSON output) with configurable parameters, designed for easy cron job integration to free up resources.
Offers queries to identify duplicate, unneeded, and missing indexes, as well as tables with high sequential scan activity, helping optimize performance based on real usage stats.
Scripts are tailored for different PostgreSQL versions (8.3-9.1 and 9.2+), ensuring functionality with appropriate output formats like pipe-delimited or JSON.
Bloat estimation only works for BTree indexes, excluding GIN, GiST, and other types, which limits usefulness for databases relying on alternative indexing strategies.
The duplicate index check reports false positives for partial and functional indexes since it only compares columns, reducing reliability and requiring manual verification.
Table bloat estimation cannot handle tables with columns that lack statistics functions, such as original JSON, leaving some data types unanalyzed.