read_from_storage(tiflash[v1]) hint doesn't work
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
### 1. Minimal reproduce step (Required)
```
drop table if exists t1;
drop view if exists v1;
create table `t1` (
`c1` varchar(50) not null,
`c2` varchar(32) default null,
`c3` varchar(256) default null,
`c4` varchar(32) not null,
`c5` int(11) default null,
`c6` bigint(20) default null,
`c7` varchar(32) default null,
`c8` int(11) default null,
`c9` varchar(100) default null,
`c10` int(11) default null,
`c11` int(11) default null,
`c12` varchar(128) default null,
`c13` bigint(20) default null,
`c14` bit(1) not null default b'0',
`c15` varchar(24) default null,
`c16` varchar(24) default null,
primary key (`c1`) /*t![clustered_index] clustered */,
key `i1` (`c5`),
key `i2` (`c6`),
key `i3` (`c4`),
key `i4` (`c2`)
) engine=innodb default charset=utf8mb4 collate=utf8mb4_bin;
alter table t1 set tiflash replica 1;
create view `v1`
(`c5`, `c17`, `c2`, `c6`, `c18`, `c4`, `c7`, `c9`, `c10`, `c11`, `c14`)
as
select
`c5`,
substring_index(substring_index(`c3`, '/', 2), '/', -1) as `c17`,
`c2`,
from_unixtime(`c6`/1000) as `c6`,
to_base64(aes_encrypt(concat('xx', `xx, `c12`), 'k1')) as `c18`,
`c4`,
`c7`,
`c9`,
`c10`,
`c11`,
`c14`
from `t1`
where `c12` not like '%null%';
select /*+ read_from_storage(tiflash[v1]) */
*
from v1
where c17 = 123456789
and c4 = 'xxx';
```
### 2. What did you expect to see? (Required)
this query should use tiflash
### 3. What did you see instead (Required)
didn't choose tiflash path
```
+----------------------------------+---------+-----------+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+----------------------------------+---------+-----------+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Projection_8 | 8.00 | root | | test.t1.c5->Column#5, substring_index(substring_index(test.t1.c3, /, 2), /, -1)->Column#17, test.t1.c2->Column#2, from_unixtime(div(cast(test.t1.c6, decimal(20,0) BINARY), 1000))->Column#18, to_base64(aes_encrypt(concat(xx, test.t1.c3, test.t1.c12), k1))->Column#19, test.t1.c4->Column#4, test.t1.c7->Column#7, test.t1.c9->Column#9, test.t1.c10->Column#10, test.t1.c11->Column#11, test.t1.c14->Column#14 |
| └─Selection_18 | 6.40 | root | | eq(cast(substring_index(substring_index(test.t1.c3, "/", 2), "/", -1), double BINARY), 1.23456789e+08) |
| └─Projection_17 | 8.00 | root | | test.t1.c2, test.t1.c3, test.t1.c4, test.t1.c5, test.t1.c6, test.t1.c7, test.t1.c9, test.t1.c10, test.t1.c11, test.t1.c12, test.t1.c14 |
| └─IndexLookUp_16 | 8.00 | root | | |
| ├─IndexRangeScan_13(Build) | 10.00 | cop[tikv] | table:t1, index:i3(c4) | range:["xxx","xxx"], keep order:false, stats:pseudo |
| └─Selection_15(Probe) | 8.00 | cop[tikv] | | not(like(test.t1.c12, "%NULL%", 92)) |
| └─TableRowIDScan_14 | 10.00 | cop[tikv] | table:t1 | keep order:false, stats:pseudo |
+----------------------------------+---------+-----------+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
TiDB root@127.0.0.1:test> show warnings;
+---------+------+--------------------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+--------------------------------------------------------------------------------------------------------------------------------------------+
| Warning | 1815 | There are no matching table names for (v1) in optimizer hint /*+ READ_FROM_STORAGE(tiflash[v1]) */. Maybe you can use the table alias name |
| Warning | 1105 | Expression about 'Column#14' can not be pushed to TiFlash because it contains unsupported calculation of type 'bit'. |
| Warning | 1105 | Scalar function 'to_base64'(signature: ToBase64, return type: var_string(543)) is not supported to push down to tiflash now. |
| Warning | 1105 | Expression about 'test.t1.c14' can not be pushed to TiFlash because it contains unsupported calculation of type 'bit'. |
| Warning | 1105 | Scalar function 'substring_index'(signature: SubstringIndex, return type: var_string(256)) is not supported to push down to tikv now. |
| Warning | 1105 | Scalar function 'to_base64'(signature: ToBase64, return type: var_string(543)) is not supported to push down to tikv now. |
| Warning | 1105 | Scalar function 'substring_index'(signature: SubstringIndex, return type: var_string(256)) is not supported to push down to tikv now. |
+---------+------+--------------------------------------------------------------------------------------------------------------------------------------------+
7 rows in set
Time: 0.003s
TiDB root@127.0.0.1:test> explain select /*+ read_from_storage(tiflash[t1]) */
-> *
-> from v1
-> where c17 = 123456789
-> and c4 = 'xxx';
+----------------------------------+---------+-----------+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+----------------------------------+---------+-----------+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Projection_8 | 8.00 | root | | test.t1.c5->Column#5, substring_index(substring_index(test.t1.c3, /, 2), /, -1)->Column#17, test.t1.c2->Column#2, from_unixtime(div(cast(test.t1.c6, decimal(20,0) BINARY), 1000))->Column#18, to_base64(aes_encrypt(concat(xx, test.t1.c3, test.t1.c12), k1))->Column#19, test.t1.c4->Column#4, test.t1.c7->Column#7, test.t1.c9->Column#9, test.t1.c10->Column#10, test.t1.c11->Column#11, test.t1.c14->Column#14 |
| └─Selection_18 | 6.40 | root | | eq(cast(substring_index(substring_index(test.t1.c3, "/", 2), "/", -1), double BINARY), 1.23456789e+08) |
| └─Projection_17 | 8.00 | root | | test.t1.c2, test.t1.c3, test.t1.c4, test.t1.c5, test.t1.c6, test.t1.c7, test.t1.c9, test.t1.c10, test.t1.c11, test.t1.c12, test.t1.c14 |
| └─IndexLookUp_16 | 8.00 | root | | |
| ├─IndexRangeScan_13(Build) | 10.00 | cop[tikv] | table:t1, index:i3(c4) | range:["xxx","xxx"], keep order:false, stats:pseudo |
| └─Selection_15(Probe) | 8.00 | cop[tikv] | | not(like(test.t1.c12, "%NULL%", 92)) |
| └─TableRowIDScan_14 | 10.00 | cop[tikv] | table:t1 | keep order:false, stats:pseudo |
+----------------------------------+---------+-----------+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
7 rows in set
Time: 0.005s
TiDB root@127.0.0.1:test> show warnings;
+---------+------+--------------------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+--------------------------------------------------------------------------------------------------------------------------------------------+
| Warning | 1815 | There are no matching table names for (t1) in optimizer hint /*+ READ_FROM_STORAGE(tiflash[t1]) */. Maybe you can use the table alias name |
| Warning | 1105 | Expression about 'Column#14' can not be pushed to TiFlash because it contains unsupported calculation of type 'bit'. |
| Warning | 1105 | Scalar function 'to_base64'(signature: ToBase64, return type: var_string(543)) is not supported to push down to tiflash now. |
| Warning | 1105 | Expression about 'test.t1.c14' can not be pushed to TiFlash because it contains unsupported calculation of type 'bit'. |
| Warning | 1105 | Scalar function 'substring_index'(signature: SubstringIndex, return type: var_string(256)) is not supported to push down to tikv now. |
| Warning | 1105 | Scalar function 'to_base64'(signature: ToBase64, return type: var_string(543)) is not supported to push down to tikv now. |
| Warning | 1105 | Scalar function 'substring_index'(signature: SubstringIndex, return type: var_string(256)) is not supported to push down to tikv now. |
+---------+------+--------------------------------------------------------------------------------------------------------------------------------------------+
7 rows in set
```
### 4. What is your TiDB version? (Required)
```
TiDB root@127.0.0.1:test> select tidb_version();
+-----------------------------------------------------------+
| tidb_version() |
+-----------------------------------------------------------+
| Release Version: v9.0.0-beta.2.pre-455-gbe3ba74ef8 |
| Edition: Community |
| Git Commit Hash: be3ba74ef819842dae045121eec5f3f6f0aaf1a7 |
| Git Branch: HEAD |
| UTC Build Time: 2025-09-06 03:59:07 |
| GoVersion: go1.23.12 |
| Race Enabled: false |
| Check Table Before Drop: false |
| Store: tikv |
| Kernel Type: Classic |
+-----------------------------------------------------------+
1 row in set
```
Contributor guide
Assessment
This issue has not been assessed yet.