ANALYZE
Description
ANALYZE TABLE collects table statistics or creates and drops column histograms.
Syntax
ANALYZE TABLE table_name [, table_name ...];
ANALYZE TABLE table_name
UPDATE HISTOGRAM ON column_name [, column_name ...]
[WITH bucket_num BUCKETS];
ANALYZE TABLE table_name
DROP HISTOGRAM ON column_name [, column_name ...];
Parameters
| Parameter | Description |
|---|---|
table_name | A table for which to collect statistics. The first syntax form accepts multiple tables. |
column_name | A column for which to create or drop a histogram. |
bucket_num | The number of histogram buckets, from 1 through 1024. If omitted, seekdb determines the value. |
Examples
Create a test table and collect table statistics:
CREATE TABLE test (c1 INT PRIMARY KEY, c2 VARCHAR(50));
ANALYZE TABLE test;
Create 30-bucket histograms for c1 and c2:
ANALYZE TABLE test UPDATE HISTOGRAM ON c1, c2 WITH 30 BUCKETS;
Drop the histogram for c2:
ANALYZE TABLE test DROP HISTOGRAM ON c2;