mysql> set @@tidb_isolation_read_engines='tiflash,tidb'; set @@tidb_allow_mpp=1;
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql> desc SELECT /*+ read_from_storage(tiflash[a]) */ COUNT(DISTINCT(a.md5_doc_id)) AS "countd(post_cnt)" FROM poc.`document_ndc_all` a JOIN poc.dim_fid_sentid b ON a.md5_doc_id = b.md5_doc_id WHERE pub_date_time BETWEEN '2021-02-22' AND '2021-05-25' AND b.folder_id IN ('108487', '100508', '100510');
+--------------------------------------------+----------+-------------------+---------------+----------------------------------------------------------------------------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+--------------------------------------------+----------+-------------------+---------------+----------------------------------------------------------------------------------------------------------------------------------------+
| HashAgg_36 | 1.00 | root | | funcs:count(distinct poc.document_ndc_all.md5_doc_id)->Column#42 |
| └─TableReader_38 | 1.00 | root | | data:ExchangeSender_37 |
| └─ExchangeSender_37 | 1.00 | batchCop[tiflash] | | ExchangeType: PassThrough |
| └─HashAgg_13 | 1.00 | batchCop[tiflash] | | group by:poc.document_ndc_all.md5_doc_id, |
| └─Projection_34 | 37.46 | batchCop[tiflash] | | poc.document_ndc_all.md5_doc_id |
| └─HashJoin_35 | 37.46 | batchCop[tiflash] | | inner join, equal:[eq(poc.dim_fid_sentid.md5_doc_id, poc.document_ndc_all.md5_doc_id)] |
| ├─ExchangeReceiver_22(Build) | 29.97 | batchCop[tiflash] | | |
| │ └─ExchangeSender_21 | 29.97 | batchCop[tiflash] | | ExchangeType: Broadcast |
| │ └─Selection_20 | 29.97 | batchCop[tiflash] | | in(poc.dim_fid_sentid.folder_id, 108487, 100508, 100510), not(isnull(poc.dim_fid_sentid.md5_doc_id)) |
| │ └─TableFullScan_19 | 10000.00 | batchCop[tiflash] | table:b | keep order:false, stats:pseudo |
| └─Selection_24(Probe) | 250.00 | batchCop[tiflash] | | ge(poc.document_ndc_all.pub_date_time, 2021-02-22 00:00:00.000000), le(poc.document_ndc_all.pub_date_time, 2021-05-25 00:00:00.000000) |
| └─TableFullScan_23 | 10000.00 | batchCop[tiflash] | table:a | keep order:false, stats:pseudo |
+--------------------------------------------+----------+-------------------+---------------+----------------------------------------------------------------------------------------------------------------------------------------+
12 rows in set (0.00 sec)
可以走 MPP执行了,应该很快,你试试看看