Updating statistics

The update statistics command updates column-related statistics such as histograms and densities. Statistics must be updated on those columns where the distribution of keys in the index changes in ways that affect the use of indexes for your queries.

Running update statistics requires system resources. Like other maintenance tasks, Sybase recommends that you schedule it during at times when the load on the server is light. In particular, update statistics requires table scans or leaf-level scans of indexes, may increase I/O contention, may use the CPU to perform sorts, and uses the data and procedure caches. Use of these resources can adversely affect queries running on the server.

Using the sampling feature can reduce resource requirements and allow more flexibility when running this task.

NoteSampling does not affect the update statistics table_name index_name parameters]. Sampling affects only update index statistics and update all statistics on unindexed columns and update statistics table_name (column_list).

In addition, some update statistics commands require shared locks, which may block updates. See “Scan types, sort requirements, and locking”.

You can also configure Adaptive Server to automatically run update statistics at times that have minimal impact on the system resources. See “Automatically updating statistics”.