Update Statistics for a Single Index
- Enterprise Edition
- Couchbase Server 7.0
You can use the
UPDATE STATISTICSstatement to gather statistics on a single index.
UPDATE STATISTICS statement provides a syntax which enables you to analyze a single index.
With this syntax, the statement gathers statistics for all the index key expressions in the specified index.
This provides a shorthand so that you do not need to list all the index key expressions explicitly.
For this syntax,
UPDATE STATISTICS FOR and
ANALYZE are synonyms.
The statement must begin with one of these alternatives.
For this syntax, the
INDEX clause enables you to specify the index name and a keyspace.
(Required) A unique name that identifies the index.
index-using ::= USING GSI
In Couchbase Server 6.5 and later, the index type for a secondary index must be Global Secondary Index (GSI).
USING GSI keywords are optional and may be omitted.
index-with ::= WITH expr
WITH clause to specify additional options.
An object with the following properties:
[Optional] An integer specifying the sample size to use for distribution statistics. A minimum sample size is also calculated. If the specified sample size is smaller than the minimum sample size, the minimum sample size is used instead.
[Optional] A float representing the percentage of documents to store in each distribution bin. If omitted, the default value is
1.0, meaning each distribution bin contains 1% of the documents, and therefore 100 bins are required. The minimum resolution is
0.02(5000 distribution bins) and the maximum is
5.0(20 distribution bins).
[Optional] A number representing a duration in seconds. The command times out when this timeout period is reached. If omitted, a default timeout value is calculated based on the number of samples used.
[Optional] Only applies when processing multiple index expressions at once. If there is a large number of index expressions to process, the cost-based optimizer deals with them in batches. This option is an integer specifying the maximum number of index expressions in each batch. If omitted, the default value is
10. You can specify a different value based on the memory availability of the system. Note that when index expressions are processed in batches, the
update_statistics_timeoutvalue (above) applies to each batch.
Refer to Distribution Statistics for more information on sample size and resolution.
UPDATE STATISTICS FOR INDEX default:`travel-sample`.inventory.airport.def_inventory_airport_city;
UPDATE STATISTICS FOR INDEX def_inventory_airport_city ON default:`travel-sample`.inventory.airport;
ANALYZE INDEX default:`travel-sample`.inventory.airport.def_inventory_airport_city;
ANALYZE INDEX def_inventory_airport_city ON default:`travel-sample`.inventory.airport;