pingcap / tidb

TiDB - the open-source, cloud-native, distributed SQL database designed for modern applications.
https://pingcap.com
Apache License 2.0
37.38k stars 5.85k forks source link

incorrect dual table query plan using vector #56500

Open wjhuang2016 opened 1 month ago

wjhuang2016 commented 1 month ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE `taf8bd821` (
  `col_49` vector DEFAULT NULL,
  `col_50` vector(2) DEFAULT NULL,
  VECTOR INDEX `idx_45`((VEC_L2_DISTANCE(`col_50`)))
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

desc SELECT `taf8bd821`.`col_49` AS `r0` FROM (`taf8bd821`)  WHERE `taf8bd821`.`col_50` BETWEEN '[0.472885, 0.023340]' AND '[0.696708, 0.030039]';

2. What did you expect to see? (Required)

TableScan

3. What did you see instead (Required)

mysql> desc SELECT `taf8bd821`.`col_49` AS `r0` FROM (`taf8bd821`)  WHERE `taf8bd821`.`col_50` BETWEEN '[0.472885, 0.023340]' AND '[0.696708, 0.030039]';
+-------------------+---------+------+---------------+-----------------------+
| id                | estRows | task | access object | operator info         |
+-------------------+---------+------+---------------+-----------------------+
| Projection_4      | 1.00    | root |               | test.taf8bd821.col_49 |
| └─TableDual_6     | 1.00    | root |               | rows:0                |
+-------------------+---------+------+---------------+-----------------------+
2 rows in set, 1 warning (0.11 sec)

4. What is your TiDB version? (Required)

master

breezewish commented 1 month ago

Update to minior severity because users will not use vectors like this, which is a rare case. However it does expose some fundenmental issues related with TiFlash Local Indexes, which may cause troubles in future when more such indexes are introduced. So we still need to resolve it, just low priority.