After restarting the TiDB component, executing SHOW STATS_HEALTHY; does not return any data

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tidb组件重启后,执行SHOW STATS_HEALTHY;查询不到任何数据

| username: TiDBer_vZIeuSNY

[TiDB Usage Environment] Production Environment
[TiDB Version]: v6.5.1
Operation: Restart TiDB Component
After restarting the TiDB component, executing SHOW STATS_HEALTHY; does not return any data. What is the issue and how can it be resolved?

| username: zhanggame1 | Original post link

Manually generate statistics for the table to see if there are any values.

| username: TiDBer_vZIeuSNY | Original post link

After manually executing ANALYZE TABLE, there will be values.

| username: tidb菜鸟一只 | Original post link

Directly use SQL to check the current table’s statistics information:

SELECT t.TABLE_SCHEMA, t.table_name, m.*, ROUND((1 - m.modify_count / m.count) * 100, 2) AS HEALTHY 
FROM mysql.stats_meta m, information_schema.tables t 
WHERE table_id = TIDB_TABLE_ID;
| username: TiDBer_vZIeuSNY | Original post link

After the TiDB component restarts, the mysql.stats_meta table is emptied and has no data.
The data is restored after manually executing ANALYZE TABLE. Is there any way to find out the reason?

| username: xingzhenxiang | Original post link

Is there a table being analyzed?

| username: TiDBer_vZIeuSNY | Original post link

There may be

| username: xingzhenxiang | Original post link

I have also encountered a similar situation where there were no results for show stats_healthy during the analyze table process.

| username: xfworld | Original post link

You can use the SHOW ANALYZE STATUS statement to query the tasks that are currently executing the ANALYZE table. This statement can display recent task records, and you can also filter the output results using the WHERE clause. For example, if you only want to see tasks analyzing columns, you can use the following statement:

SHOW ANALYZE STATUS WHERE job_info = 'analyze columns';

This statement will display information such as the table schema, table name, task information, start time, and status. If you want to see all the tasks that are currently executing, you can omit the WHERE clause. Please note that this statement only displays task records from the last 7 days. If you want to view older records, you can use the system table mysql.analyze_jobs.


Reference Documentation

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.