Skip to content

Slow Query on mysql.stats_meta Table #64571

@0xPoe

Description

@0xPoe

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. Create a huge cluster with heavy workload.
  2. Check the slow logs.

2. What did you expect to see? (Required)

No slow queries on mysql.stats_meta table.

3. What did you see instead (Required)

SELECT version, table_id, modify_count, count, snapshot, last_stats_histograms_version FROM mysql.stats_meta WHERE version > 462255440511108949 ORDER BY version;

| id                    | estRows  | estCost    | actRows | task      | access object    | execution info                                                                                                                                                                                                                                                                                                                                                                                                                                                                | operator info                                    | memory  | disk     |
| Sort_5                | 3333.33  | 2467712.52 | 587     | root      |                  | time:2.87s, loops:2                                                                                                                                                                                                                                                                                                                                                                                                                                                           | mysql.stats_meta.version                         | 42.1 KB | 0 Bytes  |
| └─TableReader_10      | 3333.33  | 487159.13  | 587     | root      |                  | time:2.87s, loops:2, cop_task: {num: 6, max: 2.87s, min: 2.42ms, avg: 499.4ms, p95: 2.87s, max_proc_keys: 85507, p95_proc_keys: 85507, tot_proc: 156ms, tot_wait: 861.5µs, copr_cache_hit_ratio: 0.00, build_task_duration: 22.9µs, max_distsql_concurrency: 6}, rpc_info:{Cop:{num_rpc:6, total_time:3s}}                                                                                                                                                                    | data:Selection_9                                 | 11.5 KB | N/A      |
|   └─Selection_9       | 3333.33  | 6040186.91 | 587     | cop[tikv] |                  | tikv_task:{proc max:2.86s, min:0s, avg: 496.7ms, p80:50ms, p95:2.86s, iters:232, tasks:6}, scan_detail: {total_process_keys: 211785, total_process_keys_size: 14752565, total_keys: 293431, get_snapshot_time: 46.7µs, rocksdb: {delete_skipped_count: 192, key_skipped_count: 361746, block: {cache_hit_count: 2006}}}, time_detail: {total_process_time: 156ms, total_suspend_time: 2.83s, total_wait_time: 861.5µs, total_kv_read_wall_time: 2.98s, tikv_wall_time: 2.99s} | gt(mysql.stats_meta.version, 462255440511108949) | N/A     | N/A      |
|     └─TableFullScan_8 | 10000.00 | 5541186.91 | 211785  | cop[tikv] | table:stats_meta | tikv_task:{proc max:2.86s, min:0s, avg: 496.7ms, p80:50ms, p95:2.86s, iters:232, tasks:6}                                                                                                                                                                                                                                                                                                                                                                                     | keep order:false, stats:pseudo                   | N/A     | N/A      |

4. What is your TiDB version? (Required)

master, 8.5.x

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions