那确实不是这个原因
执行一下,看看这两个的结果呢
select /*+ IGNORE_INDEX(t, user_id) */ user_Id from rel_user_oranization t where user_id=‘userid’
select /*+ IGNORE_INDEX(t, user_id) */ user_Id from rel_user_oranization t where user_id like ‘%userid%’ ;
这两个都能查
能查询到结果吗? 还是都未查到数据
能查到数据,是索引的问题吗,索引的数据有问题,我把索引删掉就能查了
那应该就是索引的问题了 按道理admin check table <table_name>应该会报错的
但是有的索引是主键呀,而且这种方式也不是很合理,这么多表也没法处理
导数据之后,执行一遍analyze table+admin check table。 应该很少会出现这种问题。
lighting倒过来的数据应该是不包含index吧
这两个都执行了,还是没有作用
数据过来就有问题马
备份和恢复是怎么做的呢? 全量还是库表级别的? 恢复前 table 已经在么?
add-index-by-sql= true 加上这个就好了
库级别同步的
上下游的表定义完全一样么?
使用 add-index-by-sql=false lightning 导入时,麻烦发下那次的导入配置,以及对应的日志
另外下面截图里的几个 sql,麻烦分别使用 explain 发下对应的执行计划,方便我们定位
方便的话麻烦发下表结构
你发的截图两个 sql 都是走的索引
我用你发的 create table 用 add-index-by-sql=false 的 lightning导入,没复现你说的问题
你那边能否再复现一下,复现时,跑下 admin check table ,并跑下对应 sql 的 explain
mysql> select user_id, md5(user_id) from t where user_id='aaaaabbbaaaaaaaa4320aaaaaaaaaaaa';
+----------------------------------+----------------------------------+
| user_id | md5(user_id) |
+----------------------------------+----------------------------------+
| aaaaabbbaaaaaaaa4320aaaaaaaaaaaa | 1d99dc9a2f1c31ed9ac186e8907eeb03 |
+----------------------------------+----------------------------------+
1 row in set (0.00 sec)
mysql> explain select user_id, md5(user_id) from t where user_id='aaaaabbbaaaaaaaa4320aaaaaaaaaaaa';
+--------------------------+---------+-----------+---------------------------------+---------------------------------------------------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+--------------------------+---------+-----------+---------------------------------+---------------------------------------------------------------------------------------------------------------+
| Projection_4 | 10.00 | root | | test.t.user_id, md5(test.t.user_id)->Column#5 |
| └─IndexReader_6 | 10.00 | root | | index:IndexRangeScan_5 |
| └─IndexRangeScan_5 | 10.00 | cop[tikv] | table:t, index:user_id(user_id) | range:["aaaaabbbaaaaaaaa4320aaaaaaaaaaaa","aaaaabbbaaaaaaaa4320aaaaaaaaaaaa"], keep order:false, stats:pseudo |
+--------------------------+---------+-----------+---------------------------------+---------------------------------------------------------------------------------------------------------------+
3 rows in set (0.00 sec)
mysql> select user_id, md5(user_id) from t where trim(user_id)='aaaaabbbaaaaaaaa4320aaaaaaaaaaaa';
+----------------------------------+----------------------------------+
| user_id | md5(user_id) |
+----------------------------------+----------------------------------+
| aaaaabbbaaaaaaaa4320aaaaaaaaaaaa | 1d99dc9a2f1c31ed9ac186e8907eeb03 |
+----------------------------------+----------------------------------+
1 row in set (0.01 sec)
mysql> explain select user_id, md5(user_id) from t where trim(user_id)='aaaaabbbaaaaaaaa4320aaaaaaaaaaaa';
+----------------------------+----------+-----------+---------------------------------+--------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+----------------------------+----------+-----------+---------------------------------+--------------------------------------------------------------+
| Projection_4 | 8000.00 | root | | test.t.user_id, md5(test.t.user_id)->Column#5 |
| └─Selection_13 | 8000.00 | root | | eq(trim(test.t.user_id), "aaaaabbbaaaaaaaa4320aaaaaaaaaaaa") |
| └─IndexReader_12 | 10000.00 | root | | index:IndexFullScan_11 |
| └─IndexFullScan_11 | 10000.00 | cop[tikv] | table:t, index:user_id(user_id) | keep order:false, stats:pseudo |
+----------------------------+----------+-----------+---------------------------------+--------------------------------------------------------------+
4 rows in set, 3 warnings (0.00 sec)
上下游的表定义完全一样么?