Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: analyze table test
Why does it take 13 minutes to analyze the table ‘test’ in the current cluster? The key point is that the ‘test’ table is still an empty table. The table structure is as follows:
CREATE TABLE test
(
id
int(11) NOT NULL,
PRIMARY KEY (id
) /*T![clustered_index] NONCLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
Is this table newly created? Has it been populated with test data before?
A newly created table that hasn’t had any data inserted into it yet.
Configuration information of the cluster, CPU, memory, disk type, etc.
2, 3, 4, 5, 11 tidb-server configuration: CPU: 24, Memory: 64G, Disk: NVME
pd: 3, 4, 5
tikv-12, 13, 14, CPU: 24, Memory: 64G, Disk: NVME
tiflash: 2, 11, CPU: 24, Memory: 64G, Disk: NVME
Additionally, I would like to ask, is your online statistical information collected automatically? Why is my statistical information controlled to be collected between 00:00 and 06:00, but during the day, I can still query automatic statistical information in the dashboard?
Empty table for 13 minutes… Check the cluster topology and resource utilization.
To improve performance, should we consider dropping this empty table?
Analyze can be configured to be automatic or manual. Automatic collection is single-threaded and has a very low priority, while manual processing is multi-threaded and has a high priority.
In future iterations, we will consider optimizing this collection mode to speed up the process without consuming more resources.
How about dropping and recreating it and then running it again?
Additionally, you can use SHOW TABLE XXX REGIONS
to see how much space is being used.
Take a look at the execution details and compare them with other normal analyzes to see if there are any differences.
Use EXPLAIN ANALYZE to see where the time is being spent.
Is it stuck and not moving?
In the TiDB Dashboard, there are execution details. Check that to see where the time is being spent.
The functions of \G and ; are the same. Either use \G without a semicolon or just use a semicolon “;”. Do not use “\G;” or you will get an ERROR: No query specified. However, this doesn’t affect anything. Your table indeed has no data, and it still uses the primary key index. It doesn’t seem to have any issues.
Restart the cluster service to check the situation, and monitor the server’s memory and CPU resource usage through the dashboard.