From eb96791a15dd717e9859d6ca1d55eac2c612ffce Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Thu, 19 Feb 2026 14:35:05 +0000 Subject: [PATCH 1/2] statistics: Added note about no TopN collected for unique single columns See https://github.com/pingcap/tidb/pull/66236 --- statistics.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/statistics.md b/statistics.md index 30265ab448f73..dcd364b67024e 100644 --- a/statistics.md +++ b/statistics.md @@ -110,6 +110,10 @@ Top-N values are values with the top N occurrences in a column or index. Top-N s TiDB records the values and occurrences of Top-N values. Here `N` is controlled by the `WITH NUM TOPN` parameter. The default value is 20, meaning the top 20 most frequent values are collected. The maximum value is 1024. For details about the parameter, see [Manual collection](#manual-collection). +> **Note:** +> +> When [`tidb_analyze_version = 2`](/system-variables.md#tidb_analyze_version-new-in-v510), TiDB does not collect Top-N statistics for unique indexes that contain only a single column, because each value can occur at most once. This applies to both the index statistics and the corresponding column statistics. + ## Selective statistics collection This section describes how to collect statistics selectively. From e9fb96961aea2ac275b4635cab763d58fc9aa909 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Fri, 20 Feb 2026 11:29:35 +0000 Subject: [PATCH 2/2] Update statistics.md Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- statistics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/statistics.md b/statistics.md index dcd364b67024e..e7a17ccf9ca97 100644 --- a/statistics.md +++ b/statistics.md @@ -112,7 +112,7 @@ TiDB records the values and occurrences of Top-N values. Here `N` is controlled > **Note:** > -> When [`tidb_analyze_version = 2`](/system-variables.md#tidb_analyze_version-new-in-v510), TiDB does not collect Top-N statistics for unique indexes that contain only a single column, because each value can occur at most once. This applies to both the index statistics and the corresponding column statistics. +> When [`tidb_analyze_version = 2`](/system-variables.md#tidb_analyze_version-new-in-v510), TiDB does not collect Top-N statistics for unique indexes that contain only a single column, or for the corresponding column statistics. This is because each value can occur at most once. ## Selective statistics collection