br/Lightning之后索引出问题了

有可能提供一个完整的复现问题的脚本吗?包含建表,示例数据和复现命令及步骤,这样应该能加速定位问题。

lightning过来,都是一样的

哦哦,是都走索引,我没注意,就是看到一个eq,一个range,不过后面重建索引确实就好了

datart.rel_user_organization-schema.sql (738 字节)
datart.rel_user_organization.0000000010000.sql (25.6 KB)

这是lightning的文件

用你发的这份数据,用 add-index-by-sql=false 的 lightning 导入了下,没复现出来

mysql> explain select user_id, md5(user_id) from rel_user_organization where user_id='005ef78ad3db418ba232a7bd610f9cf5';
+--------------------------+---------+-----------+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------+
| id                       | estRows | task      | access object                                       | operator info                                                                                                 |
+--------------------------+---------+-----------+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------+
| Projection_4             | 10.00   | root      |                                                     | datart.rel_user_organization.user_id, md5(datart.rel_user_organization.user_id)->Column#9                     |
| └─IndexReader_6          | 10.00   | root      |                                                     | index:IndexRangeScan_5                                                                                        |
|   └─IndexRangeScan_5     | 10.00   | cop[tikv] | table:rel_user_organization, index:user_id(user_id) | range:["005ef78ad3db418ba232a7bd610f9cf5","005ef78ad3db418ba232a7bd610f9cf5"], keep order:false, stats:pseudo |
+--------------------------+---------+-----------+-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------+
3 rows in set (0.00 sec)

mysql> select user_id, md5(user_id) from rel_user_organization where user_id='005ef78ad3db418ba232a7bd610f9cf5';
+----------------------------------+----------------------------------+
| user_id                          | md5(user_id)                     |
+----------------------------------+----------------------------------+
| 005ef78ad3db418ba232a7bd610f9cf5 | ff9886517255daf1fe78961f7a5bd35c |
+----------------------------------+----------------------------------+
1 row in set (0.01 sec)

mysql> explain select user_id, md5(user_id) from rel_user_organization where trim(user_id)='005ef78ad3db418ba232a7bd610f9cf5';
+----------------------------+----------+-----------+-----------------------------------------------------+-------------------------------------------------------------------------------------------+
| id                         | estRows  | task      | access object                                       | operator info                                                                             |
+----------------------------+----------+-----------+-----------------------------------------------------+-------------------------------------------------------------------------------------------+
| Projection_4               | 8000.00  | root      |                                                     | datart.rel_user_organization.user_id, md5(datart.rel_user_organization.user_id)->Column#9 |
| └─Selection_13             | 8000.00  | root      |                                                     | eq(trim(datart.rel_user_organization.user_id), "005ef78ad3db418ba232a7bd610f9cf5")        |
|   └─IndexReader_12         | 10000.00 | root      |                                                     | index:IndexFullScan_11                                                                    |
|     └─IndexFullScan_11     | 10000.00 | cop[tikv] | table:rel_user_organization, index:user_id(user_id) | keep order:false, stats:pseudo                                                            |
+----------------------------+----------+-----------+-----------------------------------------------------+-------------------------------------------------------------------------------------------+
4 rows in set, 3 warnings (0.00 sec)

mysql> select user_id, md5(user_id) from rel_user_organization where trim(user_id)='005ef78ad3db418ba232a7bd610f9cf5';
+----------------------------------+----------------------------------+
| user_id                          | md5(user_id)                     |
+----------------------------------+----------------------------------+
| 005ef78ad3db418ba232a7bd610f9cf5 | ff9886517255daf1fe78961f7a5bd35c |
+----------------------------------+----------------------------------+
1 row in set (0.00 sec)

mysql> SELECT count(1) from rel_user_organization where org_id ='1ce8c8c12ac24a57bb07734df5ec5120';
+----------+
| count(1) |
+----------+
|      149 |
+----------+
1 row in set (0.00 sec)

mysql> SELECT count(1) from rel_user_organization where trim(org_id) ='1ce8c8c12ac24a57bb07734df5ec5120';
+----------+
| count(1) |
+----------+
|      149 |
+----------+
1 row in set (0.00 sec)

mysql> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                               |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v7.1.1
Edition: Community
Git Commit Hash: cf441574864be63938524e7dfcf7cc659edc3dd8
Git Branch: heads/refs/tags/v7.1.1
UTC Build Time: 2023-07-19 10:07:59
GoVersion: go1.20.6
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql>

此话题已在最后回复的 60 天后被自动关闭。不再允许新回复。