Gathering hash-based statistics

Use this syntax to create hash-based statistics:

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 ]
		
update all statistics
	table_name [partition data_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 ]

update statistics
	table_name [[partition data_partition_name] 
		[ (col1, col2, …) | (col1), (col2), …] |
	[ [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]

Determine the level of hashing with [no_hashing | partial_hashing | hashing]:

See Reference Manual: Commands.

This example gathers hash-based statistics for the authors table:

update index statistics authors with hashing

Explicitly specifying hash-based statistics in an update statistics command takes precedence over the value for the update statistics hashing configuration parameter. In the example above, update statistics ... with hashing takes precedence over the server-level update statistics hashing parameter.

You cannot use the consumer and sampling parameters when you gather hash-based statistics. Adaptive Server attempts to use low-domain hash-based statistics with partial_hashing before defaulting to the sort-based statistics, which support the consumer and sampling parameters.

Hash-based update statistics allow you to specify column sets as a comma-separated list of column names in parentheses:

update statistics table_name (column1), (column2), (column3), ...

This syntax allows Adaptive Server to perform a single table scan that updates statistics on all columns. However, Adaptive Server issues an error message if you include multiple columns within the same parentheses to gather hashing statistics.