Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: tikv内22亿的表(分区表)加入到tiflash中会有风险么?
[TiDB Usage Environment] Production Environment / Test / Poc
Production Environment
[TiDB Version]
v4.0.8
[Reproduction Path] What operations were performed to cause the issue
[Encountered Issue: Problem Phenomenon and Impact]
Currently, there is a single table with 2.2 billion rows that requires an aggregate query. Executing it in TiKV takes 10 seconds, which does not meet performance requirements. Considering adding the table to TiFlash, are there any risks?
SELECT
sum(xx) AS xxx
FROM
t_xxx t
WHERE
app_xxx IN (
'aaa',
'bbb',
'ccc',
'dddd', omitted hundreds more)
AND report_time BETWEEN '2023-09-04 00:00:00'
AND '2023-09-04 23:59:59';
report_time
has a single-column index.
Execution plan is as follows:
+------------------------------+------------+-----------+------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| StreamAgg_30 | 1.00 | root | | funcs:sum(Column#134)->Column#125 |
| └─TableReader_31 | 1.00 | root | | data:StreamAgg_10 |
| └─StreamAgg_10 | 1.00 | cop[tikv] | | funcs:sum(dbname.t_xxx.xxx)->Column#134 |
| └─Selection_29 | 1228580.34 | cop[tikv] | | ge(dbname.t_xxx.report_time, 2023-09-04 00:00:00.000000), in(dbname.t_xxx.app_package, "aaa", "bbb", "ccc", "ggg", "ddd", "eee", "fff"), le(dbname.t_xxx.report_time, 2023-09-04 23:59:59.000000) |
| └─TableFullScan_28 | 6198910.00 | cop[tikv] | table:t, partition:p20230904 | keep order:false |
+------------------------------+------------+-----------+------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
[Resource Configuration] Go to TiDB Dashboard - Cluster Info - Hosts and take a screenshot of this page
[Attachments: Screenshots/Logs/Monitoring]