Please answer these questions before submitting your issue. Thanks!
the table trades is access by index rather than by TiFlash mpp plan.
mysql> explain analyze with logs_summary as (
-> select date(test_time) as test_date,
-> count(*) as log_count,
-> count(distinct transaction_hash) as tx_count_log
-> from logs
-> where date(test_time) in ('2023-09-11', '2023-09-12')
-> group by 1
-> ),
-> trades_summary as (
-> select date(test_time) as test_date,
-> count(*) as trace_count,
-> count(distinct transaction_hash) as tx_count_trace
-> from trades
-> where date(test_time) in ('2023-09-11', '2023-09-12')
-> group by 1
-> )
-> select l.test_date, l.log_count, l.tx_count_log, t.trace_count, t.tx_count_trace
-> from logs_summary l
-> inner join trades_summary t on l.test_date = t.test_date;
alter table trades alter index trades_date_idx visible;
+------------------------------------------------+----------------+--------------+-----------+--------------+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+---------+
| id | estCost | estRows | actRows | task | access object | execution info | memory | disk |
+------------------------------------------------+----------------+--------------+-----------+--------------+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+---------+
| Projection_27 | 23571646873.87 | 1.00 | 2 | root | | time:4m45.3s, loops:2, RU:1238157.818600, Concurrency:OFF | 1.86 KB | N/A |
| └─HashJoin_31 | 23571646873.37 | 1.00 | 2 | root | | time:4m45.3s, loops:2, build_hash_table:{total:4m45.3s, fetch:4m45.3s, build:9.01µs}, probe:{concurrency:5, total:23m46.7s, max:4m45.3s, probe:15.3µs, fetch:23m46.7s} | 25.9 KB | 0 Bytes |
| ├─HashAgg_32(Build) | 22587947900.68 | 1.00 | 2 | root | | time:4m45.3s, loops:2 | 247.2 MB | 0 Bytes |
| │ └─Projection_46 | 22036888876.61 | 11021194.21 | 10978886 | root | | time:4m39.1s, loops:10723, Concurrency:5 | 1.54 MB | N/A |
| │ └─IndexLookUp_45 | 22034689046.24 | 11021194.21 | 10978886 | root | | time:4m41.5s, loops:10723, index_task: {total_time: 4m44s, fetch_handle: 12s, build: 1.3ms, wait: 4m32s}, table_task: {total_time: 23m44.6s, num: 540, concurrency: 5}, next: {wait_index: 15.2ms, wait_table_lookup_build: 3.56ms, wait_table_lookup_resp: 4m40.2s} | 95.3 MB | N/A |
| │ ├─Selection_44(Build) | 4630994555.75 | 11021194.21 | 10978886 | cop[tikv] | | time:51.3ms, loops:10763, cop_task: {num: 352, max: 2.27s, min: 1.57ms, avg: 195.2ms, p95: 1.11s, max_proc_keys: 50144, p95_proc_keys: 50144, tot_proc: 15.8s, tot_wait: 601.4ms, rpc_num: 352, rpc_time: 1m8.7s, copr_cache: disabled, build_task_duration: 9.29ms, max_distsql_concurrency: 15}, tikv_task:{proc max:2.24s, min:0s, avg: 179ms, p80:110ms, p95:1.08s, iters:12120, tasks:352}, scan_detail: {total_process_keys: 10978886, total_process_keys_size: 1831781141, total_keys: 10979239, get_snapshot_time: 492.7ms, rocksdb: {key_skipped_count: 10978886, test: {cache_hit_count: 4093, read_count: 31980, read_byte: 124.5 MB, read_time: 613ms}}} | N/A | N/A |
| │ │ └─IndexRangeScan_42 | 4081036964.77 | 11021194.21 | 10978886 | cop[tikv] | table:trades, index:trades_date_idx(test_time_gen) | tikv_task:{proc max:2.24s, min:0s, avg: 177.6ms, p80:110ms, p95:1.08s, iters:12120, tasks:352} | N/A | N/A |
| │ └─TableRowIDScan_43(Probe) | 5846215848.45 | 11021194.21 | 10978886 | cop[tikv] | table:trades | time:23m37.4s, loops:12806, cop_task: {num: 6132, max: 5.69s, min: 0s, avg: 1.14s, p95: 3.42s, max_proc_keys: 11122, p95_proc_keys: 3051, tot_proc: 43m39.6s, tot_wait: 29s, rpc_num: 6131, rpc_time: 1h56m21.6s, copr_cache: disabled, build_task_duration: 3s, max_distsql_concurrency: 15, max_extra_concurrency: 1, store_batch_num: 1}, tikv_task:{proc max:1.11s, min:0s, avg: 1.12s, p80:2.05s, p95:3.4s, iters:37928, tasks:6132}, scan_detail: {total_process_keys: 10978886, total_process_keys_size: 21636960857, total_keys: 21957772, get_snapshot_time: 25s, rocksdb: {key_skipped_count: 10978886, test: {cache_hit_count: 240313674, read_count: 2516914, read_byte: 21.5 GB, read_time: 22m9.5s}}} | N/A | N/A |
| └─TableReader_85(Probe) | 977137453.36 | 314715.41 | 2 | root | | time:1.72s, loops:2, cop_task: {num: 3, max: 0s, min: 0s, avg: 0s, p95: 0s, copr_cache: disabled} | 707 Bytes | N/A |
| └─ExchangeSender_84 | 14639708911.78 | 314715.41 | 2 | mpp[tiflash] | | tiflash_task:{time:1.72s, loops:2, threads:8} | N/A | N/A |
| └─Projection_53 | 14639708911.78 | 314715.41 | 2 | mpp[tiflash] | | tiflash_task:{time:1.72s, loops:2, threads:8} | N/A | N/A |
| └─Selection_83 | 14639548003.18 | 314715.41 | 2 | mpp[tiflash] | | tiflash_task:{time:1.72s, loops:2, threads:8} | N/A | N/A |
| └─Projection_77 | 14638562043.60 | 393394.26 | 2 | mpp[tiflash] | | tiflash_task:{time:1.72s, loops:2, threads:8} | N/A | N/A |
| └─HashAgg_78 | 14638556127.85 | 393394.26 | 2 | mpp[tiflash] | | tiflash_task:{time:1.72s, loops:2, threads:8} | N/A | N/A |
| └─ExchangeReceiver_80 | 14637075144.56 | 393394.26 | 1246460 | mpp[tiflash] | | tiflash_task:{time:1.65s, loops:66, threads:8} | N/A | N/A |
| └─ExchangeSender_79 | 14415234239.39 | 393394.26 | 1246460 | mpp[tiflash] | | tiflash_task:{time:1.64s, loops:256, threads:8} | N/A | N/A |
| └─HashAgg_76 | 14415234239.39 | 393394.26 | 1246460 | mpp[tiflash] | | tiflash_task:{time:1.6s, loops:256, threads:8} | N/A | N/A |
| └─Projection_88 | 15473877639.22 | 139337405.60 | 4841107 | mpp[tiflash] | | tiflash_task:{time:1.33s, loops:82, threads:8} | N/A | N/A |
| └─Selection_66 | 13992662032.60 | 139337405.60 | 4841107 | mpp[tiflash] | | tiflash_task:{time:1.32s, loops:82, threads:8} | N/A | N/A |
| └─TableFullScan_65 | 13556137334.20 | 174171757.00 | 174174202 | mpp[tiflash] | table:logs | tiflash_task:{time:1.19s, loops:2866, threads:8}, tiflash_scan:{dtfile:{total_scanned_packs:22828, total_skipped_packs:300, total_scanned_rows:181479788, total_skipped_rows:2447654, total_rs_index_load_time: 5ms, total_read_time: 7992ms}, total_create_snapshot_time: 1ms, total_local_region_num: 0, total_remote_region_num: 0} | N/A | N/A |
+------------------------------------------------+----------------+--------------+-----------+--------------+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+---------+
20 rows in set, 3 warnings (4 min 46.45 sec)
mysql> show warnings;
+---------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Warning | 1105 | Aggregation can not be pushed to tiflash because expressions of AggFunc `firstrow` contain virtual column or correlated column, which is not supported now |
| Warning | 1105 | Aggregation can not be pushed to tiflash because expressions of AggFunc `firstrow` contain virtual column or correlated column, which is not supported now |
| Warning | 1105 | Aggregation can not be pushed to tiflash because expressions of AggFunc `firstrow` contain virtual column or correlated column, which is not supported now |
+---------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
3 rows in set (0.07 sec)
alter table trades alter index trades_date_idx invisible;
| id | estCost | estRows | actRows | task | access object | execution info | memory | disk |
+------------------------------------------------------+----------------+--------------+-----------+--------------+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+------+
| TableReader_118 | 1892486558.44 | 218439.68 | 2 | root | | time:4.11s, loops:2, RU:0.000000, cop_task: {num: 3, max: 0s, min: 0s, avg: 0s, p95: 0s, copr_cache: disabled} | 1.51 KB | N/A |
| └─ExchangeSender_117 | 28368075684.72 | 218439.68 | 2 | mpp[tiflash] | | tiflash_task:{time:4.11s, loops:2, threads:8} | N/A | N/A |
| └─Projection_116 | 28368070442.17 | 218439.68 | 2 | mpp[tiflash] | | tiflash_task:{time:4.11s, loops:2, threads:8} | N/A | N/A |
| └─HashJoin_113 | 28368065199.62 | 218439.68 | 2 | mpp[tiflash] | | tiflash_task:{time:4.11s, loops:2, threads:8} | N/A | N/A |
| ├─ExchangeReceiver_45(Build) | 13716407884.74 | 218439.68 | 2 | mpp[tiflash] | | tiflash_task:{time:4.11s, loops:2, threads:8} | N/A | N/A |
| │ └─ExchangeSender_44 | 13711165332.42 | 218439.68 | 2 | mpp[tiflash] | | tiflash_task:{time:4.11s, loops:2, threads:8} | N/A | N/A |
| │ └─Projection_34 | 13711165332.42 | 218439.68 | 2 | mpp[tiflash] | | tiflash_task:{time:4.11s, loops:2, threads:8} | N/A | N/A |
| │ └─Selection_36 | 13711058384.35 | 218439.68 | 2 | mpp[tiflash] | | tiflash_task:{time:4.11s, loops:2, threads:8} | N/A | N/A |
| │ └─Projection_40 | 13710403065.31 | 273049.60 | 2 | mpp[tiflash] | | tiflash_task:{time:4.11s, loops:2, threads:8} | N/A | N/A |
| │ └─HashAgg_41 | 13710399133.39 | 273049.60 | 2 | mpp[tiflash] | | tiflash_task:{time:4.11s, loops:2, threads:8} | N/A | N/A |
| │ └─ExchangeReceiver_43 | 13709414772.20 | 273049.60 | 2114576 | mpp[tiflash] | | tiflash_task:{time:3.94s, loops:68, threads:8} | N/A | N/A |
| │ └─ExchangeSender_42 | 13684840308.20 | 273049.60 | 2114576 | mpp[tiflash] | | tiflash_task:{time:3.92s, loops:256, threads:8} | N/A | N/A |
| │ └─HashAgg_37 | 13684840308.20 | 273049.60 | 2114576 | mpp[tiflash] | | tiflash_task:{time:3.88s, loops:256, threads:8} | N/A | N/A |
| │ └─Projection_119 | 14692217819.84 | 138182886.40 | 10978886 | mpp[tiflash] | | tiflash_task:{time:3.43s, loops:2987, threads:8} | N/A | N/A |
| │ └─Selection_39 | 13285571309.44 | 138182886.40 | 10978886 | mpp[tiflash] | | tiflash_task:{time:3.43s, loops:2987, threads:8} | N/A | N/A |
| │ └─TableFullScan_38 | 12871022650.24 | 172728608.00 | 172728608 | mpp[tiflash] | table:trades | tiflash_task:{time:3.21s, loops:2988, threads:8}, tiflash_scan:{dtfile:{total_scanned_packs:22138, total_skipped_packs:93, total_scanned_rows:172752507, total_skipped_rows:733099, total_rs_index_load_time: 10ms, total_read_time: 9488ms}, total_create_snapshot_time: 2ms, total_local_region_num: 0, total_remote_region_num: 0} | N/A | N/A |
| └─ExchangeReceiver_58(Probe) | 14650694466.47 | 327531.34 | 2 | mpp[tiflash] | | tiflash_task:{time:1.13ms, loops:2, threads:8} | N/A | N/A |
| └─ExchangeSender_57 | 14642804930.69 | 327531.34 | 2 | mpp[tiflash] | | tiflash_task:{time:3.3s, loops:2, threads:8} | N/A | N/A |
| └─Projection_47 | 14642804930.69 | 327531.34 | 2 | mpp[tiflash] | | tiflash_task:{time:3.3s, loops:2, threads:8} | N/A | N/A |
| └─Selection_49 | 14642643984.16 | 327531.34 | 2 | mpp[tiflash] | | tiflash_task:{time:3.3s, loops:2, threads:8} | N/A | N/A |
| └─Projection_53 | 14641657792.19 | 409414.17 | 2 | mpp[tiflash] | | tiflash_task:{time:3.3s, loops:2, threads:8} | N/A | N/A |
| └─HashAgg_54 | 14641651875.04 | 409414.17 | 2 | mpp[tiflash] | | tiflash_task:{time:3.3s, loops:2, threads:8} | N/A | N/A |
| └─ExchangeReceiver_56 | 14640170542.69 | 409414.17 | 1246460 | mpp[tiflash] | | tiflash_task:{time:3.23s, loops:66, threads:8} | N/A | N/A |
| └─ExchangeSender_55 | 14418277348.84 | 409414.17 | 1246460 | mpp[tiflash] | | tiflash_task:{time:3.23s, loops:256, threads:8} | N/A | N/A |
| └─HashAgg_50 | 14418277348.84 | 409414.17 | 1246460 | mpp[tiflash] | | tiflash_task:{time:3.21s, loops:256, threads:8} | N/A | N/A |
| └─Projection_120 | 15477170274.65 | 145011542.40 | 4841107 | mpp[tiflash] | | tiflash_task:{time:2.73s, loops:82, threads:8} | N/A | N/A |
| └─Selection_52 | 13995605540.33 | 145011542.40 | 4841107 | mpp[tiflash] | | tiflash_task:{time:2.73s, loops:82, threads:8} | N/A | N/A |
| └─TableFullScan_51 | 13558977951.53 | 181264428.00 | 181298674 | mpp[tiflash] | table:logs | tiflash_task:{time:2.62s, loops:3149, threads:8}, tiflash_scan:{dtfile:{total_scanned_packs:25957, total_skipped_packs:466, total_scanned_rows:206890743, total_skipped_rows:3807526, total_rs_index_load_time: 5ms, total_read_time: 10265ms}, total_create_snapshot_time: 1ms, total_local_region_num: 0, total_remote_region_num: 0} | N/A | N/A |
+------------------------------------------------------+----------------+--------------+-----------+--------------+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+------+
28 rows in set (7.01 sec)
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
mpp plan
3. What did you see instead (Required)
the table trades is access by index rather than by TiFlash mpp plan.
4. What is your TiDB version? (Required)
v7.1.1