Skip to main content
Version: current [25.0.x]

ANALYZE TABLE

Compute and delete statistics for tables, including estimated number of distinct values, number of rows, and number of null values.

After statistics have been computed, you may use them with Dremio's Query Planner tool by enabling the planner.use_statistics option.

Syntax

Syntax
ANALYZE TABLE <table_name>
FOR { ALL COLUMNS | COLUMNS ( <column_name1>, <column_name2>, ... ) }
{ COMPUTE | DELETE } STATISTICS

Parameters

<table_name> String

The path to the table that you want to generate statistics for. The source can be in the scratch directory or a data lake source.


FOR { ALL COLUMNS | COLUMNS ( <column_name1>, <column_name2>, ... ) } String

The columns that you want to generate statistics for. You can choose to either include all columns or specify one or more columns for the statistics. If you do not specify the columns, Dremio will compute statistics for all the columns contained in the table. If you want to compute statistics for specific columns, you can specify more than one column by separating each one with a comma.


{ COMPUTE | DELETE } STATISTICS String

Choose to either compute or delete statistics for the specified columns in the table.

Examples

Analyze specific column of a table
ANALYZE TABLE      reporting.test_table
FOR COLUMNS (a)
COMPUTE STATISTICS;

Analyze multiple columns of a table
ANALYZE TABLE      reporting.test_table
FOR COLUMNS (a,
b)
COMPUTE STATISTICS;