@@ -113,6 +113,7 @@ static HTAB *GroupDataFilesByPartition(List *dataFiles, TimestampTz compactionSt
113113static List * FilterCompactionCandidates (List * dataFiles , TimestampTz compactionStartTime , bool forceMerge ,
114114 bool forceCompactDeletions );
115115static List * TryCompactDataFiles (Oid relationId , TupleDesc tupleDescriptor , List * candidates ,
116+ CompactionStats * runStats ,
116117 PgLakeTableType tableType , List * options , bool forceMerge , bool isVerbose );
117118#ifdef USE_ASSERT_CHECKING
118119static void AssertAllFilesHaveSamePartition (List * dataFiles );
@@ -149,7 +150,7 @@ int TargetFileSizeMB = DEFAULT_TARGET_FILE_SIZE_MB;
149150int VacuumCompactMinInputFiles = DEFAULT_MIN_INPUT_FILES ;
150151
151152/* pg_lake_table.write_log_level */
152- int WriteLogLevel = LOG ;
153+ int WriteLogLevel = DEBUG1 ;
153154
154155
155156/*
@@ -710,7 +711,7 @@ RemoveAllDataFilesFromPgLakeCatalogFromTable(Oid relationId)
710711 */
711712bool
712713CompactDataFiles (Oid relationId , TimestampTz compactionStartTime ,
713- bool forceMerge , bool isVerbose )
714+ bool forceMerge , bool isVerbose , CompactionStats * runStats )
714715{
715716 /* prevent concurrent update/delete which might rewrite files too */
716717 LockTableForUpdate (relationId );
@@ -765,7 +766,7 @@ CompactDataFiles(Oid relationId, TimestampTz compactionStartTime,
765766 }
766767
767768 List * newFileOps = TryCompactDataFiles (relationId , tupleDescriptor , entry -> dataFiles ,
768- tableType , options , forceMerge , isVerbose );
769+ runStats , tableType , options , forceMerge , isVerbose );
769770
770771 table_close (rel , NoLock );
771772 PopActiveSnapshot ();
@@ -811,6 +812,7 @@ AssertAllFilesHaveSamePartition(List *dataFiles)
811812 */
812813static List *
813814TryCompactDataFiles (Oid relationId , TupleDesc tupleDescriptor , List * candidates ,
815+ CompactionStats * runStats ,
814816 PgLakeTableType tableType , List * options , bool forceMerge , bool isVerbose )
815817{
816818#ifdef USE_ASSERT_CHECKING
@@ -867,6 +869,14 @@ TryCompactDataFiles(Oid relationId, TupleDesc tupleDescriptor, List *candidates,
867869
868870 fileSizeSum += dataFile -> stats .fileSize ;
869871
872+ if (runStats != NULL )
873+ {
874+ runStats -> filesRemoved ++ ;
875+ runStats -> bytesRemoved += dataFile -> stats .fileSize ;
876+ runStats -> rowsRemoved += dataFile -> stats .rowCount - dataFile -> stats .deletedRowCount ;
877+ runStats -> positionDeletedRowsResolved += dataFile -> stats .deletedRowCount ;
878+ }
879+
870880 filePathsToCompact = lappend (filePathsToCompact , dataFile -> path );
871881 }
872882
@@ -953,6 +963,20 @@ TryCompactDataFiles(Oid relationId, TupleDesc tupleDescriptor, List *candidates,
953963
954964 metadataOperations = list_concat (metadataOperations , newFileOps );
955965
966+ if (runStats != NULL )
967+ {
968+ ListCell * newFileCell = NULL ;
969+
970+ foreach (newFileCell , newFileOps )
971+ {
972+ TableMetadataOperation * addOp = lfirst (newFileCell );
973+
974+ runStats -> filesAdded ++ ;
975+ runStats -> bytesAdded += addOp -> dataFileStats .fileSize ;
976+ runStats -> rowsAdded += addOp -> dataFileStats .rowCount ;
977+ }
978+ }
979+
956980 if (hasRowIds )
957981 {
958982 /* get the row ID ranges from the compacted files */
0 commit comments