mco_disk_stat

Retrieve and reset disk I/O statistics for the current database connection.

Prototype

    MCO_RET mco_disk_stat(
        /*IN*/  mco_db_h db,
        /*OUT*/ mco_disk_stat_t *ds
    );

Arguments

db
Database connection handle.
ds
Pointer to a mco_disk_stat_t structure that will receive the current disk I/O statistics.

Description

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_t structure contains:

This function is available only when MCO_CFG_SUPPORT_DISK_OBJECTS is 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.

Return Codes

MCO_S_OK
Disk statistics successfully retrieved and reset.
MCO_E_INVALID_HANDLE
The provided database handle is invalid or null.

Example

    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);
        }
    }

Files

Header file:
mco.h
Source file:
mcostat.c
Library:
libmcolib.a

See Also

mco_stat_get_disk_stats()
Get aggregated disk statistics across connections or for a specific connection without requiring a handle.