Can hint be used to force the use of TiFlash? It didn't work, and I hope experts can help check where the query is slow

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

Original topic: 可以使用hint强制使用tiflash吗?没有成功,同时希望大佬们帮忙看看语句慢在哪

| username: Jjjjayson_zeng

【TiDB Usage Environment】Production Environment
【TiDB Version】
【Reproduction Path】Using hint was unsuccessful
【Encountered Problem: Problem Phenomenon and Impact】

【Attachment: Screenshot/Log/Monitoring】

I am currently using this method to force the use of TiFlash. I don’t know how to use hint and would like to ask how to use it.
Untitled.xlsx (11.9 KB)
Test SQL.sql (11.3 KB)

| username: 啦啦啦啦啦 | Original post link

/*+ READ_FROM_STORAGE(TIFLASH[PCODE]) */
Please refer to this link:

| username: Jjjjayson_zeng | Original post link

Still using TiKV

| username: tidb菜鸟一只 | Original post link

Try collecting some statistics.

| username: 随缘天空 | Original post link

The image is not available for translation. Please provide the text content directly for translation.

| username: Holland | Original post link

You need to add --comments for it to take effect.

| username: Jjjjayson_zeng | Original post link

There must be replicas; otherwise, how could I have added TiFlash?

| username: Jjjjayson_zeng | Original post link

What does statistical information refer to?

| username: Kongdom | Original post link

Was this section of the script executed? How was it assigned?

– set @@session.tidb_isolation_read_engines=‘tikv,tiflash’;

| username: Kongdom | Original post link

ANALYZE TABLE PSNACCOUNT

| username: Kongdom | Original post link

:thinking: This is recursion, right? I wonder if it can work within recursion.

| username: Jjjjayson_zeng | Original post link

Executed it, but it didn’t work, it won’t recurse.

| username: Jjjjayson_zeng | Original post link

It’s not recursion.

| username: Jjjjayson_zeng | Original post link

Aren’t we talking about TiDB? How is this related to MySQL?

| username: TiDBer_小阿飞 | Original post link

Have you configured TiFlash in the engines section of the configuration document?
Instance level for TiDB, i.e., INSTANCE level. Add the following configuration items to the TiDB configuration file:
[isolation-read]
engines = [“tikv”, “tidb”, “tiflash”]

| username: oceanzhang | Original post link

Collect the statistics of the related tables.

| username: Jjjjayson_zeng | Original post link

How to collect, boss?

| username: heiwandou | Original post link

Analyze the table, analyze table tablename

| username: 托马斯滑板鞋 | Original post link

Check if the available replica is 1 by running select * from information_schema.tiflash_replica;.
Have all the tables in the SQL constructed TiFlash replicas? If they all have, change the engine to TiFlash.

set @@session.tidb_isolation_read_engines = "tiflash";

Then execute the SQL again.

| username: andone | Original post link

Update statistics