From 06d129c364b8c1918639aac010f319b546bb0a6f Mon Sep 17 00:00:00 2001 From: AKIRA <33112463+Kikyou1997@users.noreply.github.com> Date: Thu, 13 Jul 2023 13:51:26 +0800 Subject: [PATCH] [docs](stats) Update statistics related content #21766 1. Update grammar of `ANALYZE` 2. Add command description about how to delete a analyze job --- docs/en/docs/query-acceleration/statistics.md | 24 ++++++++++++------- .../docs/query-acceleration/statistics.md | 24 ++++++++++++------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/docs/en/docs/query-acceleration/statistics.md b/docs/en/docs/query-acceleration/statistics.md index 2ab48ebc5737cf..30dd42b1505490 100644 --- a/docs/en/docs/query-acceleration/statistics.md +++ b/docs/en/docs/query-acceleration/statistics.md @@ -187,7 +187,7 @@ mysql> ANALYZE TABLE stats_test.example_tbl(city, age, sex); ##### Collect histogram information -Column histogram information is used to describe the distribution of columns. It divides the data into several intervals (buckets) according to the size, and uses simple statistics to represent the characteristics of the data in each interval. Collected by `ANALYZE TABLE` statement fit `UPDATE HISTOGRAM`. +Column histogram information is used to describe the distribution of columns. It divides the data into several intervals (buckets) according to the size, and uses simple statistics to represent the characteristics of the data in each interval. Collected by `ANALYZE TABLE` statement fit `WITH HISTOGRAM`. Columns can be specified to collect their histogram information in the same way that normal statistics are collected. Collecting histogram information takes longer than normal statistics, so to reduce overhead, we can just collect histogram information for specific columns for the optimizer to use. @@ -196,7 +196,7 @@ Example: - Collects `example_tbl` histograms for all columns of a table, using the following syntax: ```SQL -mysql> ANALYZE TABLE stats_test.example_tbl UPDATE HISTOGRAM; +mysql> ANALYZE TABLE stats_test.example_tbl WITH HISTOGRAM; +--------+ | job_id | +--------+ @@ -207,7 +207,7 @@ mysql> ANALYZE TABLE stats_test.example_tbl UPDATE HISTOGRAM; - Collect `example_tbl` histograms for table `city` `age` `sex` columns, using the following syntax: ```SQL -mysql> ANALYZE TABLE stats_test.example_tbl(city, age, sex) UPDATE HISTOGRAM; +mysql> ANALYZE TABLE stats_test.example_tbl(city, age, sex) WITH HISTOGRAM; +--------+ | job_id | +--------+ @@ -219,7 +219,7 @@ mysql> ANALYZE TABLE stats_test.example_tbl(city, age, sex) UPDATE HISTOGRAM; ```SQL -- use with buckets -mysql> ANALYZE TABLE stats_test.example_tbl UPDATE HISTOGRAM WITH BUCKETS 2; +mysql> ANALYZE TABLE stats_test.example_tbl WITH HISTOGRAM WITH BUCKETS 2; +--------+ | job_id | +--------+ @@ -227,7 +227,7 @@ mysql> ANALYZE TABLE stats_test.example_tbl UPDATE HISTOGRAM WITH BUCKETS 2; +--------+ -- configure num.buckets -mysql> ANALYZE TABLE stats_test.example_tbl UPDATE HISTOGRAM PROPERTIES("num.buckets" = "2"); +mysql> ANALYZE TABLE stats_test.example_tbl WITH HISTOGRAM PROPERTIES("num.buckets" = "2"); +--------+ | job_id | +--------+ @@ -330,7 +330,7 @@ mysql> ANALYZE TABLE stats_test.example_tbl PROPERTIES("sample.percent" = "50"); - Samples collect `example_tbl` histogram information for a table, similar to normal statistics, using the following syntax: ```SQL -mysql> ANALYZE TABLE stats_test.example_tbl UPDATE HISTOGRAM WITH SAMPLE ROWS 5; +mysql> ANALYZE TABLE stats_test.example_tbl WITH HISTOGRAM WITH SAMPLE ROWS 5; +--------+ | job_id | +--------+ @@ -357,7 +357,7 @@ mysql> ANALYZE TABLE stats_test.example_tbl PROPERTIES("sync" = "true"); - Samples collect `example_tbl` histogram information for a table, similar to normal statistics, using the following syntax: ```SQL -mysql> ANALYZE TABLE stats_test.example_tbl UPDATE HISTOGRAM WITH SYNC; +mysql> ANALYZE TABLE stats_test.example_tbl WITH HISTOGRAM WITH SYNC; ``` ### Automatic collection @@ -393,7 +393,7 @@ mysql> ANALYZE TABLE stats_test.example_tbl PROPERTIES("period.seconds" = "86400 - Collects `example_tbl` histogram information for a table periodically (every other day), similar to normal statistics, using the following syntax: ```SQL -mysql> ANALYZE TABLE stats_test.example_tbl UPDATE HISTOGRAM WITH PERIOD 86400; +mysql> ANALYZE TABLE stats_test.example_tbl WITH HISTOGRAM WITH PERIOD 86400; +--------+ | job_id | +--------+ @@ -861,6 +861,14 @@ mysql> DROP STATS stats_test.example_tbl; mysql> DROP STATS stats_test.example_tbl(city, age, sex); ``` +## Delete Analyze Job + +User can delete automatic/periodic Analyze jobs based on job ID. + +```sql +DROP ANALYZE JOB [JOB_ID] +``` + ## ANALYZE configuration item To be added. diff --git a/docs/zh-CN/docs/query-acceleration/statistics.md b/docs/zh-CN/docs/query-acceleration/statistics.md index 9be196e79be304..901ff14b215945 100644 --- a/docs/zh-CN/docs/query-acceleration/statistics.md +++ b/docs/zh-CN/docs/query-acceleration/statistics.md @@ -218,7 +218,7 @@ mysql> ANALYZE TABLE stats_test.example_tbl(city, age, sex); ##### 收集直方图信息 -列直方图信息用于描述列分布的情况,它将数据根据大小分成若干个区间(桶),并使用简单的统计量来表示每个区间中数据的特征。通过 `ANALYZE TABLE` 语句配合 `UPDATE HISTOGRAM` 进行收集。 +列直方图信息用于描述列分布的情况,它将数据根据大小分成若干个区间(桶),并使用简单的统计量来表示每个区间中数据的特征。通过 `ANALYZE TABLE` 语句配合 `WITH HISTOGRAM` 进行收集。 和收集普通统计信息一样,可以指定列来收集其直方图信息。相比普通统计信息,收集直方图信息耗时更长,所以为了降低开销,我们可以只收集特定列的直方图信息供优化器使用。 @@ -227,7 +227,7 @@ mysql> ANALYZE TABLE stats_test.example_tbl(city, age, sex); - 收集 `example_tbl` 表所有列的直方图,使用以下语法: ```SQL -mysql> ANALYZE TABLE stats_test.example_tbl UPDATE HISTOGRAM; +mysql> ANALYZE TABLE stats_test.example_tbl WITH HISTOGRAM; +--------+ | job_id | +--------+ @@ -238,7 +238,7 @@ mysql> ANALYZE TABLE stats_test.example_tbl UPDATE HISTOGRAM; - 收集 `example_tbl` 表 `city`, `age`, `sex` 列的直方图,使用以下语法: ```SQL -mysql> ANALYZE TABLE stats_test.example_tbl(city, age, sex) UPDATE HISTOGRAM; +mysql> ANALYZE TABLE stats_test.example_tbl(city, age, sex) WITH HISTOGRAM; +--------+ | job_id | +--------+ @@ -250,7 +250,7 @@ mysql> ANALYZE TABLE stats_test.example_tbl(city, age, sex) UPDATE HISTOGRAM; ```SQL -- 使用with buckets -mysql> ANALYZE TABLE stats_test.example_tbl UPDATE HISTOGRAM WITH BUCKETS 2; +mysql> ANALYZE TABLE stats_test.example_tbl WITH HISTOGRAM WITH BUCKETS 2; +--------+ | job_id | +--------+ @@ -258,7 +258,7 @@ mysql> ANALYZE TABLE stats_test.example_tbl UPDATE HISTOGRAM WITH BUCKETS 2; +--------+ -- 配置num.buckets -mysql> ANALYZE TABLE stats_test.example_tbl UPDATE HISTOGRAM PROPERTIES("num.buckets" = "2"); +mysql> ANALYZE TABLE stats_test.example_tbl WITH HISTOGRAM PROPERTIES("num.buckets" = "2"); +--------+ | job_id | +--------+ @@ -361,7 +361,7 @@ mysql> ANALYZE TABLE stats_test.example_tbl PROPERTIES("sample.percent" = "50"); - 抽样收集 `example_tbl` 表的直方图信息,与普通统计信息类似,使用以下语法: ```SQL -mysql> ANALYZE TABLE stats_test.example_tbl UPDATE HISTOGRAM WITH SAMPLE ROWS 5; +mysql> ANALYZE TABLE stats_test.example_tbl WITH HISTOGRAM WITH SAMPLE ROWS 5; +--------+ | job_id | +--------+ @@ -388,7 +388,7 @@ mysql> ANALYZE TABLE stats_test.example_tbl PROPERTIES("sync" = "true"); - 抽样收集 `example_tbl` 表的直方图信息,与普通统计信息类似,使用以下语法: ```SQL -mysql> ANALYZE TABLE stats_test.example_tbl UPDATE HISTOGRAM WITH SYNC; +mysql> ANALYZE TABLE stats_test.example_tbl WITH HISTOGRAM WITH SYNC; ``` ### 自动收集 @@ -424,7 +424,7 @@ mysql> ANALYZE TABLE stats_test.example_tbl PROPERTIES("period.seconds" = "86400 - 周期性(每隔一天)收集 `example_tbl` 表的直方图信息,与普通统计信息类似,使用以下语法: ```SQL -mysql> ANALYZE TABLE stats_test.example_tbl UPDATE HISTOGRAM WITH PERIOD 86400; +mysql> ANALYZE TABLE stats_test.example_tbl WITH HISTOGRAM WITH PERIOD 86400; +--------+ | job_id | +--------+ @@ -924,6 +924,14 @@ mysql> DROP STATS stats_test.example_tbl; mysql> DROP STATS stats_test.example_tbl(city, age, sex); ``` +## 删除Analyze Job + +用于根据job id删除自动/周期Analyze作业 + +```sql +DROP ANALYZE JOB [JOB_ID] +``` + ## ANALYZE 配置项 待补充。