From db032481848e4640adb5c510aa33abc7270daf3a 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 84a6b9b3c6cf4f024d9f3e51f535d584459bf2d8 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 3472c1fde139b60cf475dc6d40825c1124a18e61 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 b2084804467ea..ceb0f5457cd24 100644 --- a/statistics.md +++ b/statistics.md @@ -244,7 +244,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 c6d7044a068d6b45ad3062ed94436b3dddf3bdf7 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 ceb0f5457cd24..98b4b0937fb4b 100644 --- a/statistics.md +++ b/statistics.md @@ -240,21 +240,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