Return statistics maintained for the specified index.
MCO_RET mco_index_stat_get( /*IN*/ mco_trans_h t,
/*IN*/ uint2 index_number,
/*OUT*/ mco_index_stat_h stat);
t
mco_trans_h transaction handle returned by mco_trans_start().index_number
mco_index_stat_num() then iterating from zero to the total number minus 1.stat
This function returns statistics that are maintained for the index.
Note that compound (multi-segmented) indexes can be optimized by the database runtime. The maximum number of segments (fields) in the index that is subject to optimization is set through the
MCO_MAX_INDEX_FIELD_SPECin filemcocfg.h. The default value is 5. If the number of fields in the index exceeds theMCO_MAX_INDEX_FIELD_SPECvalue, the access through the indexes not optimized. (For users with eXtremeDB source code, this value can be modified and libraries rebuilt. Note that increasingMCO_MAX_INDEX_FIELD_SPECby one adds 16 bytes to the index header. Also note that the default setting adds 80 bytes to the index header.)The application can determine whether an index has been optimized by calling
mco_index_stat_get()which returns MCO_IDXST_FEATURE_OPTIMIZED as a value of themco_index_stat_t::type.
MCO_S_OK
MCO_E_INVALID_HANDLE
MCO_E_INDEXLIMIT
Application snippet:
const char * dbname = "SimpleDb";
int main(int argc, char* argv[])
{
mco_db_h db;
MCO_RET rc;
mco_device_t dev;
mco_db_params_t db_params;
mco_trans_h t;
uint2 n_indexes;
mco_index_stat_t st;
int j;
...
rc = mco_db_open_dev(dbname, simple_get_dictionary(), &dev, 1, &db_params);
if (MCO_S_OK != rc)
{
rc = mco_db_connect(dbname, &db);
...
rc = mco_trans_start(db, MCO_READ_ONLY, MCO_TRANS_FOREGROUND, &t);
if (MCO_S_OK == rc)
{
mco_index_stat_num(t, &n_indexes);
for (j = 0; j < n_indexes && MCO_S_OK == rc; j++)
{
rc = mco_index_stat_get(t, j, &st);
if (MCO_S_OK == rc)
{
printf("%25s %4d key(s) %4d page(s)\n\t\t\t",
st.plabel, st.keys_num, st.pages_num);
}
}
...
}
}
...
}