跳到主要内容

SHOW ANALYZE

描述

该语句用来查看统计信息收集作业的状态。

语法

SHOW [AUTO] ANALYZE [ <table_name> | <job_id> ]
[ WHERE STATE = {"PENDING" | "RUNNING" | "FINISHED" | "FAILED"} ];

必选参数

可选参数

1. AUTO

展示自动作业信息。如不指定,默认显示手动作业信息。

2. <table_name>

表名。指定后可查看该表对应的作业信息。不指定时默认返回所有表的作业信息。

3. <job_id>

统计信息作业 ID,执行 ANALYZE 异步收集时得到。不指定 id 时此命令返回所有作业信息。

4. WHERE STATE = {"PENDING" | "RUNNING" | "FINISHED" | "FAILED"}

作业状态过滤条件。如不指定,默认显示所有状态的作业信息。

返回值

列名说明
job_id收集作业的唯一ID
catalog_nameCatalog名
db_name数据库名
tbl_name表名
col_name收集的列列表
job_type作业类型
analysis_type分析类型
message错误信息
last_exec_time_in_ms上次收集完成时间
state作业状态
progress作业进度
schedule_type调度类型
start_time作业开始时间
end_time作业结束时间
priority作业优先级
enable_partition是否开启分区收集

权限控制

执行此 SQL 命令的用户必须至少具有以下权限:

权限(Privilege)对象(Object)说明(Notes)
SELECT_PRIV表(Table)当执行 SHOW 时,需要拥有被查询的表的 SELECT_PRIV 权限

举例

  1. 通过表名展示作业
SHOW ANALYZE test1 WHERE STATE="FINISHED";
+---------------+--------------+---------+----------+-----------------------+----------+---------------+---------+----------------------+----------+-------------------------------------------------------+---------------+---------------------+---------------------+----------+------------------+
| job_id | catalog_name | db_name | tbl_name | col_name | job_type | analysis_type | message | last_exec_time_in_ms | state | progress | schedule_type | start_time | end_time | priority | enable_partition |
+---------------+--------------+---------+----------+-----------------------+----------+---------------+---------+----------------------+----------+-------------------------------------------------------+---------------+---------------------+---------------------+----------+------------------+
| 1737454119144 | internal | test | test1 | [test1:name,test1:id] | MANUAL | FUNDAMENTALS | | 2025-01-21 18:10:11 | FINISHED | 2 Finished | 0 Failed | 0 In Progress | 2 Total | ONCE | 2025-01-21 18:10:10 | 2025-01-21 18:10:11 | MANUAL | false |
| 1738725887879 | internal | test | test1 | [test1:name,test1:id] | MANUAL | FUNDAMENTALS | | 2025-02-05 11:26:15 | FINISHED | 2 Finished | 0 Failed | 0 In Progress | 2 Total | ONCE | 2025-02-05 11:26:15 | 2025-02-05 11:26:15 | MANUAL | false |
| 1738725887890 | internal | test | test1 | [test1:name,test1:id] | MANUAL | FUNDAMENTALS | | 2025-02-05 12:17:09 | FINISHED | 2 Finished | 0 Failed | 0 In Progress | 2 Total | ONCE | 2025-02-05 12:17:08 | 2025-02-05 12:17:09 | MANUAL | false |
| 1738725887895 | internal | test | test1 | [test1:id] | MANUAL | FUNDAMENTALS | | 2025-02-05 12:17:24 | FINISHED | 1 Finished | 0 Failed | 0 In Progress | 1 Total | ONCE | 2025-02-05 12:17:23 | 2025-02-05 12:17:24 | MANUAL | false |
| 1738725887903 | internal | test | test1 | [test1:id] | MANUAL | FUNDAMENTALS | | 2025-02-05 12:17:42 | FINISHED | 1 Finished | 0 Failed | 0 In Progress | 1 Total | ONCE | 2025-02-05 12:17:41 | 2025-02-05 12:17:42 | MANUAL | false |
+---------------+--------------+---------+----------+-----------------------+----------+---------------+---------+----------------------+----------+-------------------------------------------------------+---------------+---------------------+---------------------+----------+------------------+
  1. 通过作业 ID 展示作业
show analyze 1738725887903;
+---------------+--------------+---------+----------+------------+----------+---------------+---------+----------------------+----------+-------------------------------------------------------+---------------+---------------------+---------------------+----------+------------------+
| job_id | catalog_name | db_name | tbl_name | col_name | job_type | analysis_type | message | last_exec_time_in_ms | state | progress | schedule_type | start_time | end_time | priority | enable_partition |
+---------------+--------------+---------+----------+------------+----------+---------------+---------+----------------------+----------+-------------------------------------------------------+---------------+---------------------+---------------------+----------+------------------+
| 1738725887903 | internal | test | test1 | [test1:id] | MANUAL | FUNDAMENTALS | | 2025-02-05 12:17:42 | FINISHED | 1 Finished | 0 Failed | 0 In Progress | 1 Total | ONCE | 2025-02-05 12:17:41 | 2025-02-05 12:17:42 | MANUAL | false |
+---------------+--------------+---------+----------+------------+----------+---------------+---------+----------------------+----------+-------------------------------------------------------+---------------+---------------------+---------------------+----------+------------------+