Update Statistics for Indexes

Use update statistics when a large amount of data in an indexed column has been added, changed, or deleted.

This command helps SAP ASE make the best decisions about which indexes to use when it processes a query, by keeping it up to date about the distribution of the key values in the indexes.

When Component Integration Services is enabled, update statistics can generate accurate distribution statistics for remote tables. See the Component Integration Users Guide.

Permission to issue the update statistics command defaults to the table owner and cannot be transferred. Its syntax is:

update statistics table_name [index_name] 

If you do not specify an index name, the command updates the distribution statistics for all the indexes in the specified table. Giving an index name updates statistics only for that index.

Use sp_helpindex to find the names of indexes. See the Reference Manual: Procedures.

To update the statistics for all of the indexes, enter the name of the table:

update statistics authors 

To update the statistics only for the index on the au_id column, enter:

update statistics authors auidind 

Because Transact-SQL does not require index names to be unique in a database, you must give the name of the table with which the index is associated. SAP ASE automatically runs update statistics when you create an index on existing data.

You can set update statistics to run automatically during the time that best suits your site, and avoid running it at times that hamper your system.