planner: ILIKE fallback for FTS cannot be pushed down to TiKV
- 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)
This was found while testing the `feature/fts` branch with the Amazon review dataset. This does not affect `master`.
```sql
set @@tidb_opt_enable_alternative_logical_plans = on;
explain SELECT count(*)
FROM amazon_review
WHERE MATCH(`review_body`, `review_headline`, `product_title`)
AGAINST('stainles' IN BOOLEAN MODE);
show warnings;
```
The plan uses the FTS LIKE fallback:
```text
HashAgg
Selection: or(ifnull(ilike(review_body, "%stainles%", 92), 0), ...)
TableReader
TableFullScan table:amazon_review, cop[tikv]
```
### 2. What did you expect to see? (Required)
If the FTS fallback is intended to scan TiKV data with `ILIKE` predicates, the predicates should be pushdown-capable, or the optimizer should account for the lack of pushdown and avoid selecting this fallback when it would be too expensive.
### 3. What did you see instead (Required)
`show warnings` reports that `ILIKE` is not supported for TiKV pushdown:
```text
Warning 1105 Scalar function 'ilike'(signature: IlikeSig, return type: bigint) is not supported to push down to tikv now.
Warning 1105 Scalar function 'ilike'(signature: IlikeSig, return type: bigint) is not supported to push down to tikv now.
Warning 1105 Scalar function 'ilike'(signature: IlikeSig, return type: bigint) is not supported to push down to tikv now.
Warning 1105 Scalar function 'ilike'(signature: IlikeSig, return type: bigint) is not supported to push down to tikv now.
```
As a result, the fallback plan scans the table in TiKV and evaluates the `ILIKE` predicates at root, which can be extremely expensive for large FTS tables.
### 4. What is your TiDB version? (Required)
`feature/fts` branch after PR https://github.com/pingcap/tidb/pull/68383.
Contributor guide
Assessment
This issue has not been assessed yet.