SLOW_QUERY

    输出结果示例如下:

    1. +-------------------------------+---------------------+------+------+---------+-------+
    2. | Field | Type | Null | Key | Default | Extra |
    3. +-------------------------------+---------------------+------+------+---------+-------+
    4. | Time | timestamp(6) | NO | PRI | NULL | |
    5. | Txn_start_ts | bigint(20) unsigned | YES | | NULL | |
    6. | User | varchar(64) | YES | | NULL | |
    7. | Host | varchar(64) | YES | | NULL | |
    8. | Conn_ID | bigint(20) unsigned | YES | | NULL | |
    9. | Exec_retry_count | bigint(20) unsigned | YES | | NULL | |
    10. | Exec_retry_time | double | YES | | NULL | |
    11. | Query_time | double | YES | | NULL | |
    12. | Parse_time | double | YES | | NULL | |
    13. | Compile_time | double | YES | | NULL | |
    14. | Rewrite_time | double | YES | | NULL | |
    15. | Preproc_subqueries | bigint(20) unsigned | YES | | NULL | |
    16. | Preproc_subqueries_time | double | YES | | NULL | |
    17. | Optimize_time | double | YES | | NULL | |
    18. | Wait_TS | double | YES | | NULL | |
    19. | Prewrite_time | double | YES | | NULL | |
    20. | Wait_prewrite_binlog_time | double | YES | | NULL | |
    21. | Commit_time | double | YES | | NULL | |
    22. | Get_commit_ts_time | double | YES | | NULL | |
    23. | Commit_backoff_time | double | YES | | NULL | |
    24. | Backoff_types | varchar(64) | YES | | NULL | |
    25. | Resolve_lock_time | double | YES | | NULL | |
    26. | Local_latch_wait_time | double | YES | | NULL | |
    27. | Write_keys | bigint(22) | YES | | NULL | |
    28. | Write_size | bigint(22) | YES | | NULL | |
    29. | Prewrite_region | bigint(22) | YES | | NULL | |
    30. | Txn_retry | bigint(22) | YES | | NULL | |
    31. | Cop_time | double | YES | | NULL | |
    32. | Process_time | double | YES | | NULL | |
    33. | Wait_time | double | YES | | NULL | |
    34. | Backoff_time | double | YES | | NULL | |
    35. | LockKeys_time | double | YES | | NULL | |
    36. | Request_count | bigint(20) unsigned | YES | | NULL | |
    37. | Total_keys | bigint(20) unsigned | YES | | NULL | |
    38. | Process_keys | bigint(20) unsigned | YES | | NULL | |
    39. | Rocksdb_delete_skipped_count | bigint(20) unsigned | YES | | NULL | |
    40. | Rocksdb_key_skipped_count | bigint(20) unsigned | YES | | NULL | |
    41. | Rocksdb_block_cache_hit_count | bigint(20) unsigned | YES | | NULL | |
    42. | Rocksdb_block_read_count | bigint(20) unsigned | YES | | NULL | |
    43. | Rocksdb_block_read_byte | bigint(20) unsigned | YES | | NULL | |
    44. | DB | varchar(64) | YES | | NULL | |
    45. | Index_names | varchar(100) | YES | | NULL | |
    46. | Is_internal | tinyint(1) | YES | | NULL | |
    47. | Digest | varchar(64) | YES | | NULL | |
    48. | Stats | varchar(512) | YES | | NULL | |
    49. | Cop_proc_avg | double | YES | | NULL | |
    50. | Cop_proc_p90 | double | YES | | NULL | |
    51. | Cop_proc_max | double | YES | | NULL | |
    52. | Cop_proc_addr | varchar(64) | YES | | NULL | |
    53. | Cop_wait_avg | double | YES | | NULL | |
    54. | Cop_wait_p90 | double | YES | | NULL | |
    55. | Cop_wait_addr | varchar(64) | YES | | NULL | |
    56. | Mem_max | bigint(20) | YES | | NULL | |
    57. | KV_total | double | YES | | NULL | |
    58. | PD_total | double | YES | | NULL | |
    59. | Backoff_total | double | YES | | NULL | |
    60. | Write_sql_response_total | double | YES | | NULL | |
    61. | Result_rows | bigint(22) | YES | | NULL | |
    62. | Backoff_Detail | varchar(4096) | YES | | NULL | |
    63. | Prepared | tinyint(1) | YES | | NULL | |
    64. | Succ | tinyint(1) | YES | | NULL | |
    65. | IsExplicitTxn | tinyint(1) | YES | | NULL | |
    66. | IsWriteCacheTable | tinyint(1) | YES | | NULL | |
    67. | Plan_from_cache | tinyint(1) | YES | | NULL | |
    68. | Plan_from_binding | tinyint(1) | YES | | NULL | |
    69. | Has_more_results | tinyint(1) | YES | | NULL | |
    70. | Plan | longtext | YES | | NULL | |
    71. | Plan_digest | varchar(128) | YES | | NULL | |
    72. | Binary_plan | longtext | YES | | NULL | |
    73. | Prev_stmt | longtext | YES | | NULL | |
    74. | Query | longtext | YES | | NULL | |
    75. +-------------------------------+---------------------+------+------+---------+-------+
    76. 73 rows in set (0.000 sec)

    输出结果示例如下:

    1. +-------------------------------+---------------------+------+------+---------+-------+
    2. | Field | Type | Null | Key | Default | Extra |
    3. +-------------------------------+---------------------+------+------+---------+-------+
    4. | INSTANCE | varchar(64) | YES | | NULL | |
    5. | Time | timestamp(6) | NO | PRI | NULL | |
    6. | Txn_start_ts | bigint(20) unsigned | YES | | NULL | |
    7. | User | varchar(64) | YES | | NULL | |
    8. | Host | varchar(64) | YES | | NULL | |
    9. | Conn_ID | bigint(20) unsigned | YES | | NULL | |
    10. | Exec_retry_count | bigint(20) unsigned | YES | | NULL | |
    11. | Exec_retry_time | double | YES | | NULL | |
    12. | Query_time | double | YES | | NULL | |
    13. | Parse_time | double | YES | | NULL | |
    14. | Compile_time | double | YES | | NULL | |
    15. | Rewrite_time | double | YES | | NULL | |
    16. | Preproc_subqueries | bigint(20) unsigned | YES | | NULL | |
    17. | Preproc_subqueries_time | double | YES | | NULL | |
    18. | Optimize_time | double | YES | | NULL | |
    19. | Wait_TS | double | YES | | NULL | |
    20. | Prewrite_time | double | YES | | NULL | |
    21. | Wait_prewrite_binlog_time | double | YES | | NULL | |
    22. | Commit_time | double | YES | | NULL | |
    23. | Get_commit_ts_time | double | YES | | NULL | |
    24. | Commit_backoff_time | double | YES | | NULL | |
    25. | Backoff_types | varchar(64) | YES | | NULL | |
    26. | Resolve_lock_time | double | YES | | NULL | |
    27. | Local_latch_wait_time | double | YES | | NULL | |
    28. | Write_keys | bigint(22) | YES | | NULL | |
    29. | Write_size | bigint(22) | YES | | NULL | |
    30. | Prewrite_region | bigint(22) | YES | | NULL | |
    31. | Txn_retry | bigint(22) | YES | | NULL | |
    32. | Cop_time | double | YES | | NULL | |
    33. | Wait_time | double | YES | | NULL | |
    34. | Backoff_time | double | YES | | NULL | |
    35. | LockKeys_time | double | YES | | NULL | |
    36. | Request_count | bigint(20) unsigned | YES | | NULL | |
    37. | Total_keys | bigint(20) unsigned | YES | | NULL | |
    38. | Process_keys | bigint(20) unsigned | YES | | NULL | |
    39. | Rocksdb_delete_skipped_count | bigint(20) unsigned | YES | | NULL | |
    40. | Rocksdb_key_skipped_count | bigint(20) unsigned | YES | | NULL | |
    41. | Rocksdb_block_cache_hit_count | bigint(20) unsigned | YES | | NULL | |
    42. | Rocksdb_block_read_count | bigint(20) unsigned | YES | | NULL | |
    43. | Rocksdb_block_read_byte | bigint(20) unsigned | YES | | NULL | |
    44. | DB | varchar(64) | YES | | NULL | |
    45. | Index_names | varchar(100) | YES | | NULL | |
    46. | Is_internal | tinyint(1) | YES | | NULL | |
    47. | Digest | varchar(64) | YES | | NULL | |
    48. | Stats | varchar(512) | YES | | NULL | |
    49. | Cop_proc_avg | double | YES | | NULL | |
    50. | Cop_proc_p90 | double | YES | | NULL | |
    51. | Cop_proc_max | double | YES | | NULL | |
    52. | Cop_proc_addr | varchar(64) | YES | | NULL | |
    53. | Cop_wait_avg | double | YES | | NULL | |
    54. | Cop_wait_p90 | double | YES | | NULL | |
    55. | Cop_wait_max | double | YES | | NULL | |
    56. | Cop_wait_addr | varchar(64) | YES | | NULL | |
    57. | Mem_max | bigint(20) | YES | | NULL | |
    58. | Disk_max | bigint(20) | YES | | NULL | |
    59. | KV_total | double | YES | | NULL | |
    60. | PD_total | double | YES | | NULL | |
    61. | Backoff_total | double | YES | | NULL | |
    62. | Write_sql_response_total | double | YES | | NULL | |
    63. | Result_rows | bigint(22) | YES | | NULL | |
    64. | Backoff_Detail | varchar(4096) | YES | | NULL | |
    65. | Prepared | tinyint(1) | YES | | NULL | |
    66. | Succ | tinyint(1) | YES | | NULL | |
    67. | IsExplicitTxn | tinyint(1) | YES | | NULL | |
    68. | IsWriteCacheTable | tinyint(1) | YES | | NULL | |
    69. | Plan_from_cache | tinyint(1) | YES | | NULL | |
    70. | Plan_from_binding | tinyint(1) | YES | | NULL | |
    71. | Has_more_results | tinyint(1) | YES | | NULL | |
    72. | Plan | longtext | YES | | NULL | |
    73. | Plan_digest | varchar(128) | YES | | NULL | |
    74. | Binary_plan | longtext | YES | | NULL | |
    75. | Prev_stmt | longtext | YES | | NULL | |
    76. | Query | longtext | YES | | NULL | |
    77. +-------------------------------+---------------------+------+------+---------+-------+
    78. 74 rows in set (0.000 sec)

    输出结果示例如下:

    1. +----------------------------+----------+-----------+--------------------------+------------------------------------------------------+
    2. | id | estRows | task | access object | operator info |
    3. +----------------------------+----------+-----------+--------------------------+------------------------------------------------------+
    4. | StreamAgg_7 | 1.00 | root | | funcs:count(1)->Column#75 |
    5. | └─TableReader_13 | 10.00 | root | | data:Selection_12 |
    6. | └─Selection_12 | 10.00 | cop[tidb] | | eq(INFORMATION_SCHEMA.cluster_slow_query.user, "u1") |
    7. | └─TableFullScan_11 | 10000.00 | cop[tidb] | table:CLUSTER_SLOW_QUERY | keep order:false, stats:pseudo |
    8. +----------------------------+----------+-----------+--------------------------+------------------------------------------------------+
    9. 4 rows in set (0.00 sec)

    目前由于没有对系统表收集统计信息,所以有时会导致某些聚合算子不能下推,导致执行较慢,用户可以通过手动指定聚合下推的 SQL HINT 来将聚合算子下推,示例如下: