Update statistics

The UPDATE STATISTICS statement stores statistics about the distribution of rows on physical storage media for use by the optimizer. The database server updates data-distribution statistics for internal, relational tables; the access method updates data-distribution statistics for virtual indexes.

When a user issues an UPDATE STATISTICS statement that requires the access method to determine the distribution of data in a table, the database server calls the am_stats purpose function.

The access method can call mi_tab_update_stat_mode() to determine if the UPDATE STATISTICS statement includes the keyword HIGH or MEDIUM, each of which influences the percentage of rows that the access method should sample and the particular statistics that it should supply.

To store statistics in the statistics descriptor, the am_stats purpose function calls the various accessor functions with the name prefix mi_tstats_set. The database server copies the information from the statistics descriptor in the appropriate system catalog tables.

For information about the effects of query costs and distribution of data, see the Informix® Performance Guide.