Skip to main content

Vacuum Analysis

Vacuum Analysis is a screen that visually reconstructs the Bloating, Dead Tuple, Age, and other information provided by Top Objects from a Vacuum perspective. You can get an at-a-glance view of the Vacuum status of an instance through Summary cards, Top 5 charts, and Vacuum execution history.

  • With Vacuum Health Summary, you can quickly understand the overall Vacuum health status of the instance.

  • In Table Analysis, you can identify tables that need attention based on Dead Tuple and Bloat Size criteria.

  • With Vacuum Execution History, you can check Vacuum execution patterns and history in time series.

Note

What is Vacuum?

Because PostgreSQL uses MVCC (Multi-Version Concurrency Control), existing rows are not immediately deleted when UPDATE or DELETE is performed, but remain as Dead Tuples. Vacuum is a maintenance operation that cleans up these Dead Tuples so disk space can be reused.

If Vacuum is not executed in a timely manner, the following problems can occur:

  • Increased table Bloat: Unnecessary space increases, leading to higher disk usage and query performance degradation

  • Transaction ID Wraparound: When Transaction Age reaches the limit, a safety mechanism kicks in that automatically stops DB writes

Prerequisites

DB configuration

Grant permissions to the monitoring account so that the agent can query schema information.

-- Grant schema access permission
GRANT USAGE ON SCHEMA {schema_name} TO {DB_User};

-- Grant query permission for existing tables
GRANT SELECT ON ALL TABLES IN SCHEMA {schema_name} TO {DB_User};

-- Automatically grant query permission for tables created in the future
ALTER DEFAULT PRIVILEGES FOR USER {owner_name} IN SCHEMA {schema_name} GRANT SELECT ON TABLES TO {DB_User};
StatementDescription
GRANT USAGE ON SCHEMAGrants permission to access the schema.
GRANT SELECT ON ALL TABLES IN SCHEMAGrants query permission for existing tables in the schema.
ALTER DEFAULT PRIVILEGES ... GRANT SELECTAutomatically grants query permission for new tables created in the schema in the future.

Agent configuration

Check the following settings in whatap.conf. Since the default value of pg_object is true, collection occurs without any additional configuration.

pg_object=true
OptionTypeDefaultDescription
pg_objectbooleantrueConfigures whether to collect Top Object information. Default is true.
pg_object_hourint5Configures the collection time for Top Object information. Default is 5, collection begins at 5 AM.

Data collection sources

The data on the Vacuum Analysis screen is collected from PostgreSQL system catalogs and statistics views.

SectionMain SourceNotes
Dead Tuplespg_class, pg_namespaceQueries tuple count using pg_stat_get_live_tuples() and pg_stat_get_dead_tuples() functions.
Top Bloat Sizepg_class, pg_stats, pg_stat_user_tablesEstimates Bloat size based on column statistics (null_frac, avg_width).
Transaction Agepg_catalog.pg_database, pg_catalog.pg_settingsCalculates Transaction Age by database using age(datfrozenxid) and compares with the autovacuum_freeze_max_age setting.
Vacuum Execution Historypg_stat_progress_vacuum, pg_stat_activityQueries the progress, wait events, and query information of running Vacuum.

Analyzing Vacuum

You can analyze the table status and whether maintenance is needed based on Vacuum-related metrics. The key metrics are as follows.

Basic options

In the top filter area, you can set the time and target instance.

  • Time: Select the date to query.

  • Instance: Select the target DB instance.

Vacuum Health Summary

Provides 3 summary cards with key Vacuum-related metrics for the instance. Dead Tuples and Top Bloat Size are collected once a day (based on the pg_object_hour setting time), and the collection time is displayed in parentheses next to the card title. The Table Analysis data at the bottom is also collected at the same time.

CardDescription
Dead TuplesDisplays total Dead Tuple count and distribution by database.
Top Bloat SizeDisplays the largest table Bloat size (MB) and distribution by database.
Transaction AgeDisplays the Age of the oldest transaction and the percentage (%) against the total limit. The percentage by database can also be checked.

Dead Tuples

If Dead Tuple counts are high, Vacuum may not be executing in a timely manner. Clicking a database name filters the Table Analysis Dead Tuple Top 5 at the bottom by that database.

Note

When Dead Tuples are high

  • Execute VACUUM table_name;

  • Dead Tuples cause query performance degradation and increased disk usage.

  • Check whether Autovacuum is enabled in settings and whether the threshold is too high.

Top Bloat Size

Bloat refers to a state where a table is excessively large relative to actual data due to Dead Tuples, etc. Large Bloat wastes unnecessary disk space and degrades sequential scan performance. Clicking a database name filters the Table Analysis Bloat Size Top 5 at the bottom by that database.

Note

When Bloat Size is high

  • Execute VACUUM FULL table_name;

  • VACUUM FULL causes table locking, so it is recommended to perform it outside business hours.

  • Severe Bloat causes query performance degradation, index inefficiency, and disk waste.

  • Also check Autovacuum settings, UPDATE/DELETE patterns, and whether HOT Update is possible.

  • Using pg_repack allows space reclamation without table locking.

Transaction Age

PostgreSQL's Transaction ID can use approximately 2 billion IDs. When Transaction Age approaches this limit, XID Wraparound occurs and the DB may be forcibly shut down to prevent data corruption.

  • Agent version v2.59.01 or later is required, and data is collected at 5-second intervals.
Note

When Transaction Age is high

  • Execute VACUUM FREEZE database_name;

  • If Transaction ID exceeds 2 billion, XID wraparound occurs and the DB may be forcibly shut down to prevent data corruption.

  • Be sure to identify and resolve the cause:

    • Long-running transactions
    • Unprocessed replication slots
    • Disabled autovacuum, etc.

Threshold settings

Clicking the Threshold Settings button in the upper right of the screen allows you to set thresholds for Dead Tuples and Bloat Size. When a threshold is set, the currently configured value is displayed at the top, and cards exceeding the threshold have their background color changed so you can quickly recognize abnormal states. To clear the settings, click the Clear Settings button in the threshold settings window.

MetricSettingDescription
Dead TuplesWarning ≥Warning-level Dead Tuple count
Critical ≥Critical-level Dead Tuple count
Bloat Size (GB)Warning ≥Warning-level Bloat size (GB)
Critical ≥Critical-level Bloat size (GB)
  • When Warning is exceeded: Card background changes to orange.

  • When Critical is exceeded: Card background changes to red.

Table Analysis

Provides Top 5 charts for analyzing Vacuum-related metrics by table.

Dead Tuple Top 5

Displays the top 5 tables with the most Dead Tuples as a horizontal bar chart. Table names are displayed in database.schema.table format.

  • Tables with many Dead Tuples are in a state that requires Vacuum.

  • Detailed data can be checked using filter and table view toggle buttons.

Bloat Size Top 5

Displays the top 5 tables with the largest Bloat Size as a horizontal bar chart. The unit is bytes.

  • For tables with large Bloat Size, consider reclaiming space with VACUUM FULL or pg_repack.

  • Detailed data can be checked using filter and table view toggle buttons.

Vacuum Execution History

Displays the Vacuum execution history for the selected period as a time-series chart.

  • You can identify patterns of whether Vacuum is being executed periodically or concentrated in specific time periods.

  • If there are long intervals without Vacuum execution, Autovacuum settings should be checked.

Vacuum & Analyze History

Clicking a specific time period in the chart displays the Vacuum & Analyze History table at the bottom, where you can check details of Vacuum and Analyze operations performed in that time period (1-hour units).

ColumnDescription
TimeVacuum/Analyze execution time
DatabaseTarget database name
PhaseVacuum execution phase (e.g., scanning heap, vacuuming indexes, etc.)
PIDProcess ID that performed Vacuum
QueryExecuted Vacuum/Analyze query
Heap ScannedNumber of Heap blocks scanned
Heap TotalTotal number of Heap blocks
Heap VacuumedNumber of Heap blocks processed by Vacuum
Index VacuumNumber of index Vacuum executions
Max Dead TuplesMaximum number of Dead Tuples that can be processed at once
Dead TuplesNumber of Dead Tuples found
RuntimeVacuum execution time
Scanned %Scan ratio relative to total Heap
Vacuumed %Vacuum processing ratio relative to total Heap
Wait EventWait event name
Wait Event TypeWait event type

Configuration

Displays Vacuum-related parameters configured for the current DB instance for reference. Only Vacuum-related items among PostgreSQL's various DB parameters are selected and shown, so you can check Autovacuum behavior or I/O cost settings without connecting to the DB separately.

AUTOVACUUM SETTINGS

ParameterDescription
autovacuumWhether the Autovacuum daemon is enabled
autovacuum_max_workersMaximum number of Autovacuum worker processes that can run simultaneously
autovacuum_naptimeAutovacuum execution interval (unit: seconds)
autovacuum_vacuum_thresholdMinimum number of Dead Tuples required to trigger Vacuum
autovacuum_vacuum_scale_factorRatio of Dead Tuples to table size to trigger Vacuum
autovacuum_vacuum_cost_delayI/O cost delay time for Autovacuum (unit: milliseconds)
autovacuum_vacuum_cost_limitI/O cost limit that Autovacuum can accumulate before pausing

Autovacuum executes Vacuum on a table when Dead Tuples of autovacuum_vacuum_threshold + autovacuum_vacuum_scale_factor × table row count have occurred.

I/O IMPACT SETTINGS

ParameterDescription
vacuum_cost_page_hitCost when a page is found in shared buffer
vacuum_cost_page_missCost when a page needs to be read from disk
vacuum_cost_page_dirtyCost when a page is modified (dirtied)

Data interpretation guide

Key metrics interpretation

MetricNormalWarningCritical
Dead TuplesSmall amount relative to tableContinuously increasing trendLarge accumulation, Vacuum not running
Bloat SizeBelow 20% of table size20–50% of table sizeAbove 50% of table size
Transaction AgeBelow 5%Above 50%Above 80% → Immediate action required

Situations requiring action

  • Dead Tuples continuously increasing

    Autovacuum cannot keep up with the workload → Lower autovacuum_vacuum_scale_factor, increase autovacuum_max_workers

  • Tables with large Bloat Size

    Normal Vacuum does not return space to the OS → Consider VACUUM FULL or pg_repack (Note: VACUUM FULL causes table locking)

  • High Transaction Age ratio

    Vacuum cannot clean up old transactions → Check long-running transactions, consider running manual VACUUM FREEZE

  • Gaps in Vacuum Execution History

    Autovacuum is disabled or workers are insufficient and cannot run → Check Autovacuum settings

Analysis using Top Objects

Vacuum Analysis is a screen that visually reconstructs the Bloating, Dead Tuple, and Age information provided by Top Objects from a Vacuum perspective. Both screens are based on the same data (collected at pg_object_hour time), but provide different perspectives depending on the analysis purpose.

Comparison ItemVacuum AnalysisTop Objects
Analysis PerspectiveVacuum maintenance-focusedObject (table/index)-focused
Data ScopeBloating, Dead Tuple, Age + Vacuum execution history6 types: Bloating, Scan, DML, Analyze Time, Age, Dead Tuple
RepresentationSummary cards + Top 5 charts + time-series historySortable table list (Top N)
Unique FeaturesVacuum Health Summary, Vacuum execution history, threshold alerts, DB parameter viewScan/DML analysis, Object Detail, index analysis

Usage guide

Tip
  • For the purpose of understanding overall Vacuum status → Quickly check the current situation with Summary cards and Top 5 charts on the Vacuum Analysis screen.

  • For detailed analysis of a specific table → Analyze in detail with various tabs and sort criteria on the Top Objects screen.

  • When identifying tables that need Vacuum and then analyzing the cause, using both screens together is effective.