From 4756c4f695fb836bfb75f08bb2b051b96deef90f Mon Sep 17 00:00:00 2001 From: Grace Cai Date: Wed, 29 May 2024 15:08:57 +0800 Subject: [PATCH 1/4] Add temp.md --- temp.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 temp.md diff --git a/temp.md b/temp.md new file mode 100644 index 0000000000000..af27ff4986a7b --- /dev/null +++ b/temp.md @@ -0,0 +1 @@ +This is a test file. \ No newline at end of file From 80ce75fa03effc96988ecbf348060eccf4dcc6a5 Mon Sep 17 00:00:00 2001 From: Grace Cai Date: Wed, 29 May 2024 15:09:02 +0800 Subject: [PATCH 2/4] Delete temp.md --- temp.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 temp.md diff --git a/temp.md b/temp.md deleted file mode 100644 index af27ff4986a7b..0000000000000 --- a/temp.md +++ /dev/null @@ -1 +0,0 @@ -This is a test file. \ No newline at end of file From 4b47596f4b3cc3bf605806022ac1a8a32b98251e Mon Sep 17 00:00:00 2001 From: Grace Cai Date: Wed, 29 May 2024 15:13:03 +0800 Subject: [PATCH 3/4] Update statistics.md --- statistics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/statistics.md b/statistics.md index b6e3f1fa79b97..e052c1bab302c 100644 --- a/statistics.md +++ b/statistics.md @@ -245,7 +245,7 @@ The current sampling rate is calculated based on an adaptive algorithm. When you > **Note:** > -> Normally, `STATS_META` is more credible than `APPROXIMATE_KEYS`. However, after importing data through the methods like [TiDB Lightning](https://docs.pingcap.com/tidb/stable/tidb-lightning-overview), the result of `STATS_META` is `0`. To handle this situation, you can use `APPROXIMATE_KEYS` to calculate the sampling rate when the result of `STATS_META` is much smaller than the result of `APPROXIMATE_KEYS`. +> Normally, `STATS_META` is more credible than `APPROXIMATE_KEYS`. However, after importing data through the methods like [TiDB Lightning Physical Import Mode](/tidb-lightning/tidb-lightning-physical-import-mode.md), the result of `STATS_META` is `0`. To handle this situation, you can use `APPROXIMATE_KEYS` to calculate the sampling rate when the result of `STATS_META` is much smaller than the result of `APPROXIMATE_KEYS`. From 9d75340e987efe022d2263c9a7f61f2c3854d97a Mon Sep 17 00:00:00 2001 From: Grace Cai Date: Tue, 4 Jun 2024 15:01:16 +0800 Subject: [PATCH 4/4] Update statistics.md --- statistics.md | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/statistics.md b/statistics.md index e052c1bab302c..08540e8ab1b77 100644 --- a/statistics.md +++ b/statistics.md @@ -241,21 +241,9 @@ Before v5.3.0, TiDB uses the reservoir sampling method to collect statistics. Si The current sampling rate is calculated based on an adaptive algorithm. When you can observe the number of rows in a table using [`SHOW STATS_META`](/sql-statements/sql-statement-show-stats-meta.md), you can use this number of rows to calculate the sampling rate corresponding to 100,000 rows. If you cannot observe this number, you can use the sum of all the values in the `APPROXIMATE_KEYS` column in the results of [`SHOW TABLE REGIONS`](/sql-statements/sql-statement-show-table-regions.md) of the table as another reference to calculate the sampling rate. - - > **Note:** > -> Normally, `STATS_META` is more credible than `APPROXIMATE_KEYS`. However, after importing data through the methods like [TiDB Lightning Physical Import Mode](/tidb-lightning/tidb-lightning-physical-import-mode.md), the result of `STATS_META` is `0`. To handle this situation, you can use `APPROXIMATE_KEYS` to calculate the sampling rate when the result of `STATS_META` is much smaller than the result of `APPROXIMATE_KEYS`. - - - - - -> **Note:** -> -> Normally, `STATS_META` is more credible than `APPROXIMATE_KEYS`. However, after importing data through TiDB Cloud console (see [Import Sample Data](/tidb-cloud/import-sample-data.md)), the result of `STATS_META` is `0`. To handle this situation, you can use `APPROXIMATE_KEYS` to calculate the sampling rate when the result of `STATS_META` is much smaller than the result of `APPROXIMATE_KEYS`. - - +> Normally, `STATS_META` is more credible than `APPROXIMATE_KEYS`. However, when the result of `STATS_META` is much smaller than the result of `APPROXIMATE_KEYS`, it is recommended that you use `APPROXIMATE_KEYS` to calculate the sampling rate. ### The memory quota for collecting statistics