这里是sql大佬
MySQL [test]> explain SELECT /*+ read_from_storage(tiflash[a,b,c,d,e]) */ date_time DIV 60 * 60 AS “time”, b.status AS metric, count(TXN_STATUS) AS “count” FROM records A join payment_status b on b.statusid=A.TXN_STATUS JOIN channels c ON A.channel_id = c.channel_id JOIN channel_master d ON c.pg_id=d.pg_id JOIN payment_way e ON e.pgid = d.pgid WHERE date_time >= 1731389400 AND date_time <= 1731393000 AND if(‘’,A.profileid=‘’,1=1) and txn_status in(‘1’,‘2’,‘3’,‘4’,‘5’,‘6’,‘7’,‘8’,‘9’,‘10’,‘11’,‘12’,‘13’,‘14’,‘15’,‘16’,‘17’,‘18’,‘19’,‘20’,‘21’,‘22’,‘23’,‘24’,‘25’,‘26’,‘27’,‘28’,‘29’,‘30’,‘31’,‘32’,‘33’,‘34’,‘35’,‘36’,‘37’,‘38’,‘39’,‘40’,‘41’,‘42’,‘43’,‘44’,‘45’,‘46’,‘47’) and txn_type in(‘pg’,‘pos’,‘ppc’,‘remit’,‘rtgs’,‘upi’,‘va’,‘wallet’) AND c.pg_id in (‘48’,‘1’,‘2’,‘179’,‘233’,‘218’,‘33’,‘93’,‘166’,‘205’,‘248’,‘14’,‘153’,‘175’,‘60’,‘217’,‘32’,‘165’,‘201’,‘247’,‘77’,‘174’,‘230’,‘6’,‘216’,‘31’,‘281’,‘279’,‘180’,‘115’,‘198’,‘4’,‘193’,‘50’,‘100’,‘108’,‘269’,‘53’,‘8’,‘120’,‘78’,‘91’,‘143’,‘138’,‘112’,‘265’,‘232’,‘274’,‘57’,‘98’,‘263’,‘262’,‘183’,‘261’,‘210’,‘144’,‘260’,‘259’,‘258’,‘271’,‘273’,‘257’,‘256’,‘267’,‘255’,‘79’,‘266’,‘181’,‘264’,‘64’,‘275’,‘176’,‘85’,‘280’,‘94’,‘195’,‘90’,‘236’,‘253’,‘246’,‘278’,‘202’,‘113’,‘276’,‘116’,‘196’,‘235’,‘254’,‘139’,‘252’,‘142’,‘272’,‘239’,‘207’,‘199’,‘251’,‘277’) GROUP BY 1,2 ORDER BY date_time DIV 60 * 60;
±-----------------------------------------------------±------------±-------------±--------------±------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
±-----------------------------------------------------±------------±-------------±--------------±------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Projection_24 | 1238.29 | root | | Column#94->Column#95, test.payment_status.status, Column#93->Column#97 |
| └─Projection_78 | 1238.29 | root | | Column#94, test.payment_status.status, Column#93, test.records.date_time |
| └─Sort_26 | 1238.29 | root | | Column#104 |
| └─Projection_79 | 1238.29 | root | | Column#94, test.payment_status.status, Column#93, test.records.date_time, mul(intdiv(cast(test.records.date_time, decimal(20,0) UNSIGNED BINARY), 60), 60)->Column#104 |
| └─Projection_27 | 1238.29 | root | | mul(intdiv(cast(test.records.date_time, decimal(20,0) UNSIGNED BINARY), 60), 60)->Column#94, test.payment_status.status, Column#93, test.records.date_time |
| └─HashAgg_30 | 1238.29 | root | | group by:Column#102, Column#103, funcs:count(Column#99)->Column#93, funcs:firstrow(Column#100)->test.records.date_time, funcs:firstrow(Column#101)->test.payment_status.status |
| └─Projection_77 | 8706.92 | root | | test.records.txn_status->Column#99, test.records.date_time->Column#100, test.payment_status.status->Column#101, mul(intdiv(cast(test.records.date_time, decimal(20,0) UNSIGNED BINARY), 60), 60)->Column#102, test.payment_status.status->Column#103 |
| └─Projection_31 | 8706.92 | root | | test.records.txn_status, test.records.date_time, test.payment_status.status |
| └─HashJoin_35 | 8706.92 | root | | inner join, equal:[eq(test.channel_master.pgid, test.payment_way.pgid)] |
| ├─TableReader_75(Build) | 232.00 | root | | MppVersion: 2, data:ExchangeSender_74 |
| │ └─ExchangeSender_74 | 232.00 | mpp[tiflash] | | ExchangeType: PassThrough |
| │ └─TableFullScan_73 | 232.00 | mpp[tiflash] | table:e | keep order:false |
| └─HashJoin_46(Probe) | 6965.54 | root | | inner join, equal:[eq(test.channels.pg_id, test.channel_master.pg_id)] |
| ├─TableDual_72(Build) | 175.00 | root | | rows:0 |
| └─HashJoin_54(Probe) | 8733.27 | root | | inner join, equal:[eq(test.records.channel_id, test.channels.channel_id)] |
| ├─HashJoin_61(Build) | 8689.47 | root | | inner join, equal:[eq(test.payment_status.statusid, test.records.txn_status)] |
| │ ├─TableDual_63(Build) | 47.00 | root | | rows:0 |
| │ └─TableReader_67(Probe) | 6951.58 | root | | MppVersion: 2, data:ExchangeSender_66 |
| │ └─ExchangeSender_66 | 6951.58 | mpp[tiflash] | | ExchangeType: PassThrough |
| │ └─Selection_65 | 6951.58 | mpp[tiflash] | | in(test.records.txn_status, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47), in(test.records.txn_type, “pg”, “pos”, “ppc”, “remit”, “rtgs”, “upi”, “va”, “wallet”), not(isnull(test.records.channel_id)) |
| │ └─TableFullScan_64 | 13774.77 | mpp[tiflash] | table:A | pushed down filter:ge(test.records.date_time, 1.7313894e+09), le(test.records.date_time, 1.731393e+09), keep order:false |
| └─TableReader_71(Probe) | 22163122.46 | root | | MppVersion: 2, data:ExchangeSender_70 |
| └─ExchangeSender_70 | 22163122.46 | mpp[tiflash] | | ExchangeType: PassThrough |
| └─Selection_69 | 22163122.46 | mpp[tiflash] | | in(test.channels.pg_id, 48, 1, 2, 179, 233, 218, 33, 93, 166, 205, 248, 14, 153, 175, 60, 217, 32, 165, 201, 247, 77, 174, 230, 6, 216, 31, 281, 279, 180, 115, 198, 4, 193, 50, 100, 108, 269, 53, 8, 120, 78, 91, 143, 138, 112, 265, 232, 274, 57, 98, 263, 262, 183, 261, 210, 144, 260, 259, 258, 271, 273, 257, 256, 267, 255, 79, 266, 181, 264, 64, 275, 176, 85, 280, 94, 195, 90, 236, 253, 246, 278, 202, 113, 276, 116, 196, 235, 254, 139, 252, 142, 272, 239, 207, 199, 251, 277) |
| └─TableFullScan_68 | 29440982.00 | mpp[tiflash] | table:c | pushed down filter:empty, keep order:false |
±-----------------------------------------------------±------------±-------------±--------------±------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
25 rows in set, 5 warnings (0.01 sec)