ANALYZE TABLE test

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

Original topic: analyze table test

| username: yulei7633

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

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

Is this table newly created? Has it been populated with test data before?

| username: yulei7633 | Original post link

A newly created table that hasn’t had any data inserted into it yet.

| username: xfworld | Original post link

Configuration information of the cluster, CPU, memory, disk type, etc.

| username: yulei7633 | Original post link

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?

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

Empty table for 13 minutes… Check the cluster topology and resource utilization.

| username: Fly-bird | Original post link

To improve performance, should we consider dropping this empty table?

| username: xfworld | Original post link

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.

| username: zhanggame1 | Original post link

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.

| username: 路在何chu | Original post link

Take a look at the execution details and compare them with other normal analyzes to see if there are any differences.

| username: TiDBer_小阿飞 | Original post link

Use EXPLAIN ANALYZE to see where the time is being spent.

| username: yulei7633 | Original post link

Is it stuck and not moving?

| username: 路在何chu | Original post link

In the TiDB Dashboard, there are execution details. Check that to see where the time is being spent.

| username: TiDBer_小阿飞 | Original post link

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.

| username: 像风一样的男子 | Original post link

Is the disk I/O normal?

| username: 随缘天空 | Original post link

Restart the cluster service to check the situation, and monitor the server’s memory and CPU resource usage through the dashboard.