Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Database Tools
  3. pgsql-bloat-estimation

pgsql-bloat-estimation

BSD-2-Clause

SQL queries to estimate statistical bloat in PostgreSQL tables and btree indexes.

GitHubGitHub
576 stars102 forks0 contributors

What is pgsql-bloat-estimation?

pgsql-bloat-estimation is a collection of SQL queries designed to estimate statistical bloat in PostgreSQL tables and btree indexes. It helps database administrators identify unused space caused by alignment padding, fillfactor settings, and actual bloat, enabling better storage management and maintenance planning. The tool provides metrics like extra size, bloat size, and percentages to assess database efficiency.

Target Audience

PostgreSQL database administrators and developers responsible for database performance, storage optimization, and maintenance tasks who need to monitor and reduce bloat.

Value Proposition

It offers a lightweight, query-based approach to bloat estimation directly within PostgreSQL, without external dependencies, and includes accuracy flags to filter unreliable stats, making it a trusted tool for informed database upkeep.

Overview

Queries to mesure statistical bloat in indexes and tables for PostgreSQL

Use Cases

Best For

  • Monitoring PostgreSQL table and index storage efficiency
  • Identifying when vacuum or autovacuum maintenance is needed
  • Analyzing bloat in btree indexes for performance tuning
  • Estimating alignment padding and fillfactor impact on disk usage
  • Database administrators needing statistical insights into space waste
  • Educational purposes to understand PostgreSQL storage internals

Not Ideal For

  • Projects needing automated, real-time bloat monitoring with alerting systems
  • Databases heavily using toasted fields or the 'name' data type where statistics are unreliable
  • Small-scale databases with predominantly tiny tables, where natural bloat percentages are misleading
  • Environments where database users lack superuser access for optimal index bloat query performance

Pros & Cons

Pros

Statistical Accuracy Flags

Includes an is_na column to filter out unreliable statistics, such as for 'name' types or missing stats, ensuring users know when to distrust the data, as noted in the caveats section.

Detailed Bloat Metrics

Provides comprehensive fields like real_size, extra_size, bloat_size, and percentages, helping pinpoint exact storage inefficiencies in tables and btree indexes, with clear documentation on each metric.

Superuser-Optimized Queries

Offers a faster query for index bloat analysis when executed by a superuser, improving performance for large databases, as specified in the btree bloat section.

Transparent Caveats

Clearly documents limitations, such as issues with toasted fields and alignment padding, allowing informed interpretation of results, which is emphasized in the README's caveats.

Cons

Toasted Field Inaccuracy

Cannot accurately estimate bloat for toasted fields, as statistics don't account for compressed or sliced data, potentially leading to negative or underestimated bloat, a limitation admitted in the README.

Alignment Padding Inclusion

Bloat estimates always include alignment padding, which is necessary CPU optimization space, not true bloat, requiring manual adjustment for accurate analysis, as warned in the caveats.

Manual Execution Required

Requires running SQL queries manually without built-in automation or scheduling, making it less suitable for continuous monitoring compared to integrated tools.

Frequently Asked Questions

Quick Stats

Stars576
Forks102
Contributors0
Open Issues4
Last commit3 years ago
CreatedSince 2015

Tags

#sql-queries#database-maintenance#storage-optimization#database-administration#postgresql#performance-monitoring

Built With

P
PostgreSQL

Included in

Database Tools5.1k
Auto-fetched 1 day ago

Related Projects

pgx_scriptspgx_scripts

A collection of useful little scripts for database analysis and administration, created by our team at PostgreSQL Experts.

Stars1,468
Forks244
Last commit2 years ago
postgres_dbapostgres_dba

The missing set of useful tools for Postgres DBAs and all engineers

Stars1,275
Forks145
Last commit2 months ago
pg-utilspg-utils

Useful PostgreSQL utilities

Stars1,213
Forks233
Last commit14 days ago
TPTTPT

Tanel Poder's Performance & Troubleshooting Tools for Oracle Databases

Stars729
Forks334
Last commit1 month ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub