Updates the statistics for all columns in an index.
update index statistics table_name [[partition data_partition_name] | [ [index_name [partition index_partition_name]]] [using step values] [with consumers = consumers] [, sampling=N [percent]] [, no_hashing | partial_hashing | hashing] [, max_resource_granularity = N percent]] [, histogram_tuning_factor = int] [, print_progress = int]
The steps are applied to each partition of a partitioned table—for example, update index statistics uses the default value of 20 steps for each data and index partition involved in the scan for updating statistics. If global statistics are generated through an index scan of a global index, then 20 steps are applied by default. If partition statistics are generated, either through a data scan or local index scan, then 20 steps are applied by default for each partition.
If the histogram steps specified through using step values is M, and the histogram_tuning_factor parameter is N, then update index statistics uses between 0 and M*N steps, depending on the number of frequency cells that update index statistics isolates and whether any range cells exist.
no_hashing – (the default) update index statistics uses the algorithm from SAP ASE versions earlier than 15.7, gathering sort-based statistics.
partial_hashing – update index statistics uses the algorithm for columns with fewer than 65536 unique values. If update index statistics encounters unique column counts that are greater than or equal to the 65536 threshold, it uses an extra scan with a sort.
hashing – update index statistics uses low-domain and high-domain hashing to create the histograms.
0 – (the default) command does not display any progress messages
1 – command displays progress messages
update index statistics authors
update index statistics authors au_names_ix
update index statistics authors au_names_ix with sampling = 20 percent
The statistics for the leading column of au_names_ix is gathered using a full scan of the index pages; sampling is not applied on this column.
update index statistics bigtable with partial_hashing, print_progress=1
Update Statistics STARTED. Update Statistics index scan started on index 'bigtable_NC1'. ...It is using existing index scan to hash minor column 'a2' (column id = 2). ...Column 'a2' (column id = 2) is moved from hashing to sorting. Update Statistics table scan started on table 'bigtable' for summary statistics. Update Statistics table scan started on table 'bigtable'. ...Sorting started for column 'a2' (column id = 2). Update Statistics FINISHED.
update index statistics publishers publish1_idx partition p1
update index statistics, when used with a table name and an index name, updates statistics for all columns in the specified index. If update index statistics is used with just a table name, it updates statistics for all columns in all indexes of the table.
If you run update index statistics against large tables, the command fails with error number 1105 if tempdb is not large enough to process the command.
Specifying the name of an unindexed column or the nonleading column of an index generates statistics for that column without creating an index.
Histogram statistics are created for each column of indexes whose statistics is being updated.
Density statistics are created for all the prefix subsets of the columns of index (es) whose statistics are being updated.
If you use update index statistics on a specific partition, you update global statistics implicitly as well.
The partition statistics serve as input to global statistics creation and enable per-partition DDL operations. Global statistics are used by the optimizer.
update index statistics also regenerates and updates the table statistics stored in systabstats for each data and index partition of the table the command updates. If you run the update index statistics command for a specific data partition, the table statistitics are generated and updated only for that data partition and for any local index partitions. Global indexes are skipped. If you run the update index statistics for a specific index partition, only the table statistics for that index partition are updated.
The with consumers clause is designed for use on partitioned tables on RAID devices, which appear to the SAP ASE server as a single I/O device, but which are capable of producing the high throughput required for parallel sorting.
update statistics salesdetail sales_det_ix update statistics salesdetail (ord_num) update statistics salesdetail (title_id)
The partial_hashing parameter uses hashing on columns only when it produces histograms that are as accurate and of equivalent quality as those produced by sorting (low-domain cases), otherwise, the partial_hashing parameter uses sorting for high-domain cases.
Hashing in high-domain cases may produce histograms with up to a 50 percent fewer steps compared to sorting.
Although hash-based statistics do not require the tempdb disk space or procedure cache memory used by sorting, it may use a significant amount of tempdb buffer cache memory.
Large sorts used for the no_hashing parameter may scavenge statements in the statement cache and stored procedures to release procedure cache memory to support the sort.
max_resource_granularity limits the amount of tempdb buffer cache memory used for hashing or partial_hashing. It does not affect the amount of memory used by the no_hashing parameter or sorting.
If you include the partial_hashing parameter, and a previous histogram on a column exists that indicates a high-domain column, then the SAP ASE server assumes that sort-based statistics are required on this column. If no previous histogram exists on a column, then the SAP ASE server assumes this column is low-domain until the high-domain limit is reached.
See also Parallel Sorting in the Performance and Tuning Guide.
ANSI SQL – Compliance level: Transact-SQL extension.
You must be the table owner or a user with update statistics permission on the table to run update index statistics.