double scanned_tuples; /* counts only tuples on scanned pages */
double old_rel_tuples; /* previous value of pg_class.reltuples */
double new_rel_tuples; /* new estimated total # of tuples */
+ double new_dead_tuples; /* new estimated total # of dead tuples */
BlockNumber pages_removed;
double tuples_deleted;
BlockNumber nonempty_pages; /* actually, last nonempty page + 1 */
BlockNumber new_rel_pages;
double new_rel_tuples;
BlockNumber new_rel_allvisible;
+ double new_live_tuples;
TransactionId new_frozen_xid;
MultiXactId new_min_multi;
new_min_multi);
/* report results to the stats collector, too */
+ new_live_tuples = new_rel_tuples - vacrelstats->new_dead_tuples;
+ if (new_live_tuples < 0)
+ new_live_tuples = 0; /* just in case */
+
pgstat_report_vacuum(RelationGetRelid(onerel),
onerel->rd_rel->relisshared,
- new_rel_tuples);
+ new_live_tuples,
+ vacrelstats->new_dead_tuples);
/* and log the action if appropriate */
if (IsAutoVacuumWorkerProcess() && Log_autovacuum_min_duration >= 0)
ereport(LOG,
(errmsg("automatic vacuum of table \"%s.%s.%s\": index scans: %d\n"
"pages: %d removed, %d remain\n"
- "tuples: %.0f removed, %.0f remain\n"
+ "tuples: %.0f removed, %.0f remain, %.0f are dead but not yet removable\n"
"buffer usage: %d hits, %d misses, %d dirtied\n"
"avg read rate: %.3f MB/s, avg write rate: %.3f MB/s\n"
"system usage: %s",
vacrelstats->rel_pages,
vacrelstats->tuples_deleted,
vacrelstats->new_rel_tuples,
+ vacrelstats->new_dead_tuples,
VacuumPageHit,
VacuumPageMiss,
VacuumPageDirty,
/* save stats for use later */
vacrelstats->scanned_tuples = num_tuples;
vacrelstats->tuples_deleted = tups_vacuumed;
+ vacrelstats->new_dead_tuples = nkeep;
/* now we can compute the new value for pg_class.reltuples */
vacrelstats->new_rel_tuples = vac_estimate_reltuples(onerel, false,
* ---------
*/
void
-pgstat_report_vacuum(Oid tableoid, bool shared, PgStat_Counter tuples)
+pgstat_report_vacuum(Oid tableoid, bool shared,
+ PgStat_Counter livetuples, PgStat_Counter deadtuples)
{
PgStat_MsgVacuum msg;
msg.m_tableoid = tableoid;
msg.m_autovacuum = IsAutoVacuumWorkerProcess();
msg.m_vacuumtime = GetCurrentTimestamp();
- msg.m_tuples = tuples;
+ msg.m_live_tuples = livetuples;
+ msg.m_dead_tuples = deadtuples;
pgstat_send(&msg, sizeof(msg));
}
tabentry = pgstat_get_tab_entry(dbentry, msg->m_tableoid, true);
- tabentry->n_live_tuples = msg->m_tuples;
- /* Resetting dead_tuples to 0 is an approximation ... */
- tabentry->n_dead_tuples = 0;
+ tabentry->n_live_tuples = msg->m_live_tuples;
+ tabentry->n_dead_tuples = msg->m_dead_tuples;
if (msg->m_autovacuum)
{
Oid m_tableoid;
bool m_autovacuum;
TimestampTz m_vacuumtime;
- PgStat_Counter m_tuples;
+ PgStat_Counter m_live_tuples;
+ PgStat_Counter m_dead_tuples;
} PgStat_MsgVacuum;
extern void pgstat_report_autovac(Oid dboid);
extern void pgstat_report_vacuum(Oid tableoid, bool shared,
- PgStat_Counter tuples);
+ PgStat_Counter livetuples, PgStat_Counter deadtuples);
extern void pgstat_report_analyze(Relation rel,
PgStat_Counter livetuples, PgStat_Counter deadtuples);