# mco_stat_get_all
RT

> Retrieve and optionally reset aggregated runtime statistics for all active database connections.

### Prototype

        MCO_RET mco_stat_get_all(
            /*OUT*/ mco_conn_statistics_t out_stats,
            /*IN*/  int reset
        );

### Arguments

`out_stats`
Pointer to an array of `mco_stat_counter_value` with size `MCO_STATRT_TOTAL_COUNTERS`. The function writes the aggregated values of all registered counters into this array.
`reset`
Flag indicating whether to clear the per-connection counters after reading:

- `0` — only read the values (no reset),
- non-zero — read and reset all per-connection counters to zero.

### Description

> This function aggregates statistics from all active database connections. It sums the values of each counter (e.g., transaction counts, timing metrics) and stores the result in the provided output array.

> If the `reset` flag is non-zero, the function also clears the individual counters in every active connection after aggregation. This enables atomic “read-and-clear” behavior useful for periodic monitoring or delta-based reporting.

> The order of counters in the output array matches the registration order (including built-in counters like `MCO_STATRT_COMMIT_COUNT`, `MCO_STATRT_MAX_TRANS_TIME`, etc.).

> Note: This function requires that at least one database with statistics support has been opened.

### Return Codes

`MCO_S_OK`
Statistics successfully aggregated and (optionally) reset.
`MCO_E_NOINSTANCE`
No databases are currently open.
Other error codes
May include registry access errors or internal system failures.

### Files

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