Adaptive Server’s cost-based optimizer uses statistics about the tables, indexes, and columns named in a query to estimate query costs. It chooses the access method that the optimizer determines has the least cost. But this cost estimate cannot be accurate if statistics are not accurate.
Sybase Central uses a wizard to update the statistics for a table.
update statistics updates the column-related statistics such as histograms and densities. Statistics need to 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 the update statistics wizard requires system resources. Like other maintenance tasks, it should be scheduled at times when 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 if you run update statistics at times when usage is high. In addition, some update statistics commands require shared locks, which can block updates.
Job Scheduler must be enabled before you configure update statistics to run automatically. The update statistics wizard includes the datachange threshold screen for configuring automatic update statistics only for Adaptive Server release 15.0 and later.
Only a table owner or a database owner can update index statistics
When update statistics run is determined by the datachange function. datachange measures the amount of change in the data distribution since update statistics last ran. Specifically, it measures the number of inserts, updates, and deletes that have occurred on the given object, partition, or column, and helps you determine if invoking update statistics would benefit the query plan.
Once you set it to run automatically, update statistics runs when its threshold is less than or equal to the value of datachange.
See the Adaptive Server Reference Manual: Commands for more information about datachange.
Only a table owner or a database owner can update index statistics.
To start the update statistics wizard
Select the index whose statistics you are updating.
Select File | Update Statistics.
Follow the steps in the Update Statistics wizard.
Right-click the index icon. Select Update Statistics from the shortcut menu.
After running update statistics, recompile
the table for which the index is defined. This ensures that the
procedures and triggers that use the index will use the new key
distribution.