@@ -466,6 +466,7 @@ MonitoringSnapshot::MonitoringSnapshot(thread_db* tdbb, MemoryPool& pool)
466466 const auto ctx_var_buffer = allocBuffer (tdbb, pool, rel_mon_ctx_vars);
467467 const auto mem_usage_buffer = allocBuffer (tdbb, pool, rel_mon_mem_usage);
468468 const auto tab_stat_buffer = allocBuffer (tdbb, pool, rel_mon_tab_stats);
469+ const auto ts_stat_buffer = allocBuffer (tdbb, pool, rel_mon_ts_stats);
469470
470471 // Increment the global monitor generation
471472
@@ -601,6 +602,9 @@ MonitoringSnapshot::MonitoringSnapshot(thread_db* tdbb, MemoryPool& pool)
601602 case rel_mon_tab_stats:
602603 buffer = tab_stat_buffer;
603604 break ;
605+ case rel_mon_ts_stats:
606+ buffer = ts_stat_buffer;
607+ break ;
604608 default :
605609 fb_assert (false );
606610 }
@@ -862,6 +866,32 @@ void SnapshotData::putField(thread_db* tdbb, Record* record, const DumpField& fi
862866 from_desc.makeBoolean (&value);
863867 MOV_move (tdbb, &from_desc, &to_desc);
864868 }
869+ else if (field.type == VALUE_TABLESPACE_ID)
870+ {
871+ // special case: translate tablespace ID into name
872+ fb_assert (field.length == sizeof (ULONG));
873+ ULONG pageSpaceId;
874+ memcpy (&pageSpaceId, field.data , field.length );
875+
876+ MetaName name;
877+
878+ if (pageSpaceId == 0 )
879+ name = TEMP_TABLESPACE_NAME;
880+ else if (pageSpaceId == DB_PAGE_SPACE)
881+ name = PRIMARY_TABLESPACE_NAME;
882+ else if (PageSpace::isTablespace (pageSpaceId))
883+ {
884+ if (const auto tablespace = MET_tablespace_id (tdbb, pageSpaceId))
885+ name = tablespace->name ;
886+ }
887+
888+ if (name.hasData ())
889+ {
890+ dsc from_desc;
891+ from_desc.makeText (name.length (), CS_METADATA, (UCHAR*) name.c_str ());
892+ MOV_move (tdbb, &from_desc, &to_desc);
893+ }
894+ }
865895 else
866896 {
867897 fb_assert (false );
@@ -1449,7 +1479,33 @@ void Monitoring::putStatistics(SnapshotData::DumpRecord& record, const RuntimeSt
14491479 record.storeInteger (f_mon_rec_imgc, statistics[RecordStatType::IMGC]);
14501480 record.write ();
14511481
1452- // logical I/O statistics (table wise)
1482+ // physical I/O statistics (per tablespace)
1483+
1484+ for (const auto & counts : statistics.getPageCounters ())
1485+ {
1486+ if (counts.isEmpty ())
1487+ continue ;
1488+
1489+ const auto io_stat_id = getGlobalId (fb_utils::genUniqueId ());
1490+
1491+ record.reset (rel_mon_ts_stats);
1492+ record.storeGlobalId (f_mon_ts_stat_id, id);
1493+ record.storeInteger (f_mon_ts_stat_group, stat_group);
1494+ record.storeTablespaceId (f_mon_ts_name, counts.getGroupId ());
1495+ record.storeGlobalId (f_mon_tab_io_stat_id, io_stat_id);
1496+ record.write ();
1497+
1498+ record.reset (rel_mon_io_stats);
1499+ record.storeGlobalId (f_mon_io_stat_id, io_stat_id);
1500+ record.storeInteger (f_mon_io_stat_group, stat_group);
1501+ record.storeInteger (f_mon_io_page_reads, counts[PageStatType::READS]);
1502+ record.storeInteger (f_mon_io_page_writes, counts[PageStatType::WRITES]);
1503+ record.storeInteger (f_mon_io_page_fetches, counts[PageStatType::FETCHES]);
1504+ record.storeInteger (f_mon_io_page_marks, counts[PageStatType::MARKS]);
1505+ record.write ();
1506+ }
1507+
1508+ // logical I/O statistics (per table)
14531509
14541510 for (const auto & counts : statistics.getTableCounters ())
14551511 {
0 commit comments