@@ -739,6 +739,7 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
739739 {
740740 StringInfoData buf ;
741741 char * msgfmt ;
742+ BlockNumber orig_rel_pages ;
742743
743744 TimestampDifference (starttime , endtime , & secs , & usecs );
744745
@@ -796,34 +797,27 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
796797 (long long ) vacrel -> new_rel_tuples ,
797798 (long long ) vacrel -> new_dead_tuples ,
798799 OldestXmin );
799- appendStringInfo (& buf ,
800- _ ("buffer usage: %lld hits, %lld misses, %lld dirtied\n" ),
801- (long long ) VacuumPageHit ,
802- (long long ) VacuumPageMiss ,
803- (long long ) VacuumPageDirty );
804- if (vacrel -> rel_pages > 0 )
800+ orig_rel_pages = vacrel -> rel_pages + vacrel -> pages_removed ;
801+ if (orig_rel_pages > 0 )
805802 {
806- BlockNumber orig_rel_pages ;
807-
808803 if (vacrel -> do_index_vacuuming )
809804 {
810- msgfmt = _ ("%u pages from table (%.2f%% of total) had %lld dead item identifiers removed\n" );
811-
812805 if (vacrel -> nindexes == 0 || vacrel -> num_index_scans == 0 )
813806 appendStringInfoString (& buf , _ ("index scan not needed: " ));
814807 else
815808 appendStringInfoString (& buf , _ ("index scan needed: " ));
809+
810+ msgfmt = _ ("%u pages from table (%.2f%% of total) had %lld dead item identifiers removed\n" );
816811 }
817812 else
818813 {
819- msgfmt = _ ("%u pages from table (%.2f%% of total) have %lld dead item identifiers\n" );
820-
821814 if (!vacrel -> failsafe_active )
822815 appendStringInfoString (& buf , _ ("index scan bypassed: " ));
823816 else
824817 appendStringInfoString (& buf , _ ("index scan bypassed by failsafe: " ));
818+
819+ msgfmt = _ ("%u pages from table (%.2f%% of total) have %lld dead item identifiers\n" );
825820 }
826- orig_rel_pages = vacrel -> rel_pages + vacrel -> pages_removed ;
827821 appendStringInfo (& buf , msgfmt ,
828822 vacrel -> lpdead_item_pages ,
829823 100.0 * vacrel -> lpdead_item_pages / orig_rel_pages ,
@@ -844,8 +838,6 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
844838 istat -> pages_deleted ,
845839 istat -> pages_free );
846840 }
847- appendStringInfo (& buf , _ ("avg read rate: %.3f MB/s, avg write rate: %.3f MB/s\n" ),
848- read_rate , write_rate );
849841 if (track_io_timing )
850842 {
851843 appendStringInfoString (& buf , _ ("I/O timings:" ));
@@ -859,12 +851,19 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
859851 (double ) (pgStatBlockWriteTime - startwritetime ) / 1000 );
860852 appendStringInfoChar (& buf , '\n' );
861853 }
862- appendStringInfo (& buf , _ ("system usage: %s\n" ), pg_rusage_show (& ru0 ));
854+ appendStringInfo (& buf , _ ("avg read rate: %.3f MB/s, avg write rate: %.3f MB/s\n" ),
855+ read_rate , write_rate );
856+ appendStringInfo (& buf ,
857+ _ ("buffer usage: %lld hits, %lld misses, %lld dirtied\n" ),
858+ (long long ) VacuumPageHit ,
859+ (long long ) VacuumPageMiss ,
860+ (long long ) VacuumPageDirty );
863861 appendStringInfo (& buf ,
864- _ ("WAL usage: %lld records, %lld full page images, %llu bytes" ),
862+ _ ("WAL usage: %lld records, %lld full page images, %llu bytes\n " ),
865863 (long long ) walusage .wal_records ,
866864 (long long ) walusage .wal_fpi ,
867865 (unsigned long long ) walusage .wal_bytes );
866+ appendStringInfo (& buf , _ ("system usage: %s" ), pg_rusage_show (& ru0 ));
868867
869868 ereport (LOG ,
870869 (errmsg_internal ("%s" , buf .data )));
0 commit comments