# Collecting Statistics with ANALYZE TABLE

## Overview

In MariaDB ColumnStore 6, the [ExeMgr process](/docs/analytics/mariadb-columnstore/architecture/mariadb-enterprise-columnstore-query-evaluation.md#exemgr-processfacility) uses optimizer statistics in its query planning process.

ColumnStore uses the optimizer statistics to add support for queries that contain circular inner joins.

In ColumnStore 5 and before, ColumnStore would raise the following error when a query containing a circular inner join was executed:

```sql
ERROR 1815 (HY000): Internal error: IDB-1003: Circular joins are not supported.
```

The optimizer statistics store each column's NDV (Number of Distinct Values), which can help the ExeMgr process choose the optimal join order for queries with circular joins. When Enterprise ColumnStore executes a query with a circular join, the query's execution can take longer if ColumnStore chooses a sub-optimal join order. When you collect optimizer statistics for your ColumnStore tables, the ExeMgr process is less likely to choose a sub-optimal join order.

Enterprise ColumnStore's optimizer statistics can be collected for ColumnStore tables by executing [ANALYZE TABLE](/docs/server/reference/sql-statements/table-statements/analyze-table.md):

```sql
[[analyze-table|ANALYZE TABLE]] columnstore_tab;
```

ColumnStore's optimizer statistics are not updated automatically. To update the optimizer statistics for a ColumnStore table, [ANALYZE TABLE](/docs/server/reference/sql-statements/table-statements/analyze-table.md) must be re-executed.

ColumnStore does not implement an interface to show optimizer statistics.

<sub>*This page is: Copyright © 2025 MariaDB. All rights reserved.*</sub>

{% @marketo/form formId="4316" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/analytics/mariadb-columnstore/high-availability/columnstore-query-tuning/collect-statistics-with-analyze-table-for-mariadb-enterprise-columnstore.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
