Created TiFlash replicas, but queries do not use Flash

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 创建了tiflash副本,查询的时候不走flash

| username: 今天不想写代码

[TiDB Usage Environment] Production Environment
[TiDB Version] 6.5
[Reproduction Path] Operations performed that led to the issue
[Encountered Issue: Issue Phenomenon and Impact]
[Resource Configuration]
[Attachments: Screenshots/Logs/Monitoring]
Data volume is slightly over 4 million


| username: 今天不想写代码 | Original post link

Supplementary SQL

DESC SELECT status, (count(*) / (SELECT count(*) FROM course_history WHERE course_date >= '2023-09-01' AND course_date <= '2023-09-27')) * 100 AS percent 
FROM course_history 
WHERE course_date >= '2023-09-01' AND course_date <= '2023-09-26' 
GROUP BY status;
| username: TiDBer_oHSwKxOH | Original post link

There is cop computation. Refresh the statistics or force it to use TiFlash.

| username: 今天不想写代码 | Original post link

Could you please provide some guidance on how to refresh and force refresh?

| username: wzf0072 | Original post link

READ_FROM_STORAGE(TIFLASH[t1_name [, tl_name …]], TIKV[t2_name [, tl_name …]])

Force to use TiKV or TiFlash (remember to give the table an alias)
SELECT /*+ READ_FROM_STORAGE(TIFLASH[t1], TIKV[t2]) */ t1.a FROM t t1, t t2 WHERE t1.a = t2.a;

| username: wzf0072 | Original post link

Alternatively, specify using TiKV or TiFlash at the session level:
Session level: set session tidb_isolation_read_engines = tiflash;

Refresh table statistics:
analyze table course_history;

| username: 今天不想写代码 | Original post link

Thanks, it has been optimized from 1.2s to 0.3s.

| username: Fly-bird | Original post link

I learned this, we didn’t use TiFlash.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.