ANALYZE_STATUS

The ANALYZE_STATUS table provides information about the running tasks that collect statistics and a limited number of history tasks.

Starting from TiDB v6.1.0, the ANALYZE_STATUS table supports showing cluster-level tasks. Even after a TiDB restart, you can still view task records before the restart using this table. Before TiDB v6.1.0, the ANALYZE_STATUS table can only show instance-level tasks, and task records are cleared after a TiDB restart.

Starting from TiDB v6.1.0, you can view the history tasks within the last 7 days through the system table mysql.analyze_jobs.

  1. USE information_schema;
  2. DESC analyze_status;
  1. +----------------+---------------------+------+------+---------+-------+
  2. | Field | Type | Null | Key | Default | Extra |
  3. +----------------+---------------------+------+------+---------+-------+
  4. | TABLE_SCHEMA | varchar(64) | YES | | NULL | |
  5. | TABLE_NAME | varchar(64) | YES | | NULL | |
  6. | PARTITION_NAME | varchar(64) | YES | | NULL | |
  7. | JOB_INFO | longtext | YES | | NULL | |
  8. | PROCESSED_ROWS | bigint(64) unsigned | YES | | NULL | |
  9. | START_TIME | datetime | YES | | NULL | |
  10. | END_TIME | datetime | YES | | NULL | |
  11. | STATE | varchar(64) | YES | | NULL | |
  12. | FAIL_REASON | longtext | YES | | NULL | |
  13. | INSTANCE | varchar(512) | YES | | NULL | |
  14. | PROCESS_ID | bigint(64) unsigned | YES | | NULL | |
  15. +----------------+---------------------+------+------+---------+-------+
  16. 11 rows in set (0.00 sec)
  1. SELECT * FROM information_schema.analyze_status;
  1. +--------------+------------+----------------+--------------------------------------------------------------------+----------------+---------------------+---------------------+----------+-------------+----------------+------------+
  2. | TABLE_SCHEMA | TABLE_NAME | PARTITION_NAME | JOB_INFO | PROCESSED_ROWS | START_TIME | END_TIME | STATE | FAIL_REASON | INSTANCE | PROCESS_ID |
  3. +--------------+------------+----------------+--------------------------------------------------------------------+----------------+---------------------+---------------------+----------+-------------+----------------+------------+
  4. | test | t | p1 | analyze table all columns with 256 buckets, 500 topn, 1 samplerate | 0 | 2022-05-27 11:30:12 | 2022-05-27 11:30:12 | finished | NULL | 127.0.0.1:4000 | NULL |
  5. | test | t | p0 | analyze table all columns with 256 buckets, 500 topn, 1 samplerate | 0 | 2022-05-27 11:30:12 | 2022-05-27 11:30:12 | finished | NULL | 127.0.0.1:4000 | NULL |
  6. | test | t | p1 | analyze index idx | 0 | 2022-05-27 11:29:46 | 2022-05-27 11:29:46 | finished | NULL | 127.0.0.1:4000 | NULL |
  7. | test | t | p0 | analyze index idx | 0 | 2022-05-27 11:29:46 | 2022-05-27 11:29:46 | finished | NULL | 127.0.0.1:4000 | NULL |
  8. | test | t | p1 | analyze columns | 0 | 2022-05-27 11:29:46 | 2022-05-27 11:29:46 | finished | NULL | 127.0.0.1:4000 | NULL |
  9. | test | t | p0 | analyze columns | 0 | 2022-05-27 11:29:46 | 2022-05-27 11:29:46 | finished | NULL | 127.0.0.1:4000 | NULL |
  10. +--------------+------------+----------------+--------------------------------------------------------------------+----------------+---------------------+---------------------+----------+-------------+----------------+------------+
  11. 6 rows in set (0.00 sec)

Fields in the ANALYZE_STATUS table are described as follows:

  • TABLE_SCHEMA: The name of the database to which the table belongs.
  • TABLE_NAME: The name of the table.
  • PARTITION_NAME: The name of the partitioned table.
  • JOB_INFO: The information of the ANALYZE task. If an index is analyzed, this information will include the index name. When tidb_analyze_version =2, this information will include configuration items such as sample rate.
  • PROCESSED_ROWS: The number of rows that have been processed.
  • START_TIME: The start time of the ANALYZE task.
  • END_TIME: The end time of the ANALYZE task.
  • STATE: The execution status of the ANALYZE task. Its value can be pending, running,finished or failed.
  • FAIL_REASON: The reason why the task fails. If the execution is successful, the value is NULL.
  • INSTANCE: The TiDB instance that executes the task.
  • PROCESS_ID: The process ID that executes the task.