Retrieve and reset disk I/O statistics for the current database connection.
MCO_RET mco_disk_stat(
/*IN*/ mco_db_h db,
/*OUT*/ mco_disk_stat_t *ds
);
db
ds
mco_disk_stat_t structure that will receive the current disk I/O statistics.This function retrieves low-level disk I/O metrics for the specified database connection, including counts and timing data for read, write, and synchronization operations. After copying the statistics into the output structure, it resets the internal counters to zero.
The
mco_disk_stat_tstructure contains:
db_total_read,db_total_write,db_sync_count— number of operations,db_total_read_time,db_total_write_time,db_total_sync_time— cumulative time spent in each operation type,db_max_read_time,db_max_write_time,db_max_sync_time— peak (maximum) time observed for a single operation.This function is available only when
MCO_CFG_SUPPORT_DISK_OBJECTSis enabled at build time.Note: The statistics are per-connection and reflect only I/O performed by this specific connection since the last call to
mco_disk_stat()or connection start.
MCO_S_OK
MCO_E_INVALID_HANDLE
mco_db_h db;
mco_disk_stat_t stats;
MCO_RET rc;
rc = mco_db_connect("mydb", &db);
if (rc == MCO_S_OK) {
// Perform some I/O operations...
rc = mco_disk_stat(db, &stats);
if (rc == MCO_S_OK) {
printf("Reads: %llu, Total read time: %llu µs\n",
stats.db_total_read, stats.db_total_read_time);
printf("Max write time: %llu µs\n", stats.db_max_write_time);
}
}