Calculate the amount of memory required to store runtime statistics for a database instance.
mco_size_t mco_stat_memsize(void);
This function computes the total size (in bytes) of the memory block needed to store all registered statistics counters and histograms for a single database instance.
The size depends on:
- The number of registered counters (via
mco_statrt_register_counter()),- The number of counters with histogram collection enabled.
This value is used internally during database initialization to allocate the statistics memory region. It may also be useful for custom memory management or static buffer sizing in embedded environments.
Note: The result is valid only after all calls to
mco_statrt_register_counter()have been made and before any database is opened. Subsequent registrations will change the required size.
mco_size_t
// Register custom counters first
mco_statrt_register_counter("my_counter", MCO_NO);
mco_statrt_register_counter("latency", MCO_YES);
// Now query required memory size
mco_size_t stat_size = mco_stat_memsize();
printf("Statistics memory required: %zu bytes\n", stat_size);