MATCH (h:TAG_A)<-[e:REFERENCES_A_AND_B]-(p:TAG_B) where 1==1 and e.hoid==“hoid33” and h.hoid==“hoid11” return h
如上查询语句,已建立TAG_A的单索引并重构,已建立TAG_B的单索引并重构。
单独一个条件能查询出数据,2个条件查询没有数据。如何才能查询出数据来呢?看手册好像不能跨点建立组合索引把。
wey
2021 年11 月 26 日 03:25
2
抱歉,这是一个问题 ,这种情况应该能降级到全扫描才对,对它的修复已经 merged 了哈
opened 02:21AM - 02 Nov 21 UTC
closed 11:51AM - 23 Nov 21 UTC
bug
### Currently, Indexes of match statements have the following degradation relate… d issues:
#### 1. `FullTagScan` cannot be degraded if the index is not selected
```
(czp@nebula) [nba]> show tag indexes
+---------------------+----------+----------+
| Index Name | By Tag | Columns |
+---------------------+----------+----------+
| "player_name_index" | "player" | ["name"] |
+---------------------+----------+----------+
| "team_name_index" | "team" | ["name"] |
+---------------------+----------+----------+
Got 2 rows (time spent 2985/3978 us)
Query 1:
match (v:player)
return v
Query 2:
match (v:player)
where v.age>40
return v
```
Query 1(expected): FullTagScan
Query 2(unexpected): The execution result is an error. The expectation is to degenerate to `FullTagScan` when there is no index on player(age).
#### 2. A low-priority index cannot be degraded if a high-priority index is not selected
```
(czp@nebula) [nba]> show tag indexes
+---------------------+----------+----------+
| Index Name | By Tag | Columns |
+---------------------+----------+----------+
| "player_name_index" | "player" | ["name"] |
+---------------------+----------+----------+
| "team_name_index" | "team" | ["name"] |
+---------------------+----------+----------+
Got 2 rows (time spent 3728/4894 us)
Query 3:
match (v:player)
where v.name=="Tim"
return v
Query 4:
match (v:player)
where v.name=="Tim" and v.age==40
return v
```
Query 3(expected): PrefixIndex(player.name)
Query 4(unexpected): The execution result is an error. The expectation is to degenerate to `PrefixIndex(player.name)` when there is no index on player(name,age).
#### 3. The composite index was not selected as expected
```
(czp@nebula) [nba]> show tag indexes
+----------------------+----------+-----------------+
| Index Name | By Tag | Columns |
+----------------------+----------+-----------------+
| "player_age_index" | "player" | ["age"] |
+----------------------+----------+-----------------+
| "player_multi_index" | "player" | ["name", "age"] |
+----------------------+----------+-----------------+
| "player_name_index" | "player" | ["name"] |
+----------------------+----------+-----------------+
| "team_name_index" | "team" | ["name"] |
+----------------------+----------+-----------------+
Got 4 rows (time spent 3328/4334 us)
Query 5:
match (v:player)--(n:team)
where v.name=="Tim" and v.age>40
return v
Query 6:
match (v:player)--(n:team)
where v.name=="Tim" and v.age>40 and v.name=="Tim"
return v
```
Query 5(expected): CompositeIndex(name,age)
Query 6(unexpected): The execution result is an error. The expected index is CompositeIndex(name,age)
vesoft-inc:master
← czpmango:fix-index
opened 06:10AM - 12 Nov 21 UTC
Fixes [https://github.com/vesoft-inc/nebula/issues/3246](https://github.com/veso… ft-inc/nebula/issues/3246)
update: 见楼下,是点索引没 rebuild 成功造成的。
wey
2021 年11 月 26 日 03:26
3
另外,您想表达的是 e.hoid==“hoid33” 还是 p.hoid==“hoid33”?确定不是写错了?
wey
2021 年11 月 26 日 03:29
5
能用 nightly 的版本试一下能不能查出来么?
我发现了e的索引建立成功了。h的索引建立不成功导致查询无数据也并不报错无索引提示。
然后,看了下,h的另一个字段name已经建立了索引,所以只能组合另一个建立了索引的字段来进行查询。
MATCH (h:TAG_A)<-[e:REFERENCES_A_AND_B]-(p:TAG_B) where 1==1 and e.hoid==“hoid33” and h.name==“name11” return h
但是,有个问题,比如我要用h的另一个字段hoid作为条件查询怎么办呢?好像同一个点只能建立一个单索引?
wey
2021 年11 月 26 日 03:41
8
如果 h 索引有了的话,从 h 通过 e 拓展(并按条件过滤)的话 e 的索引应该不是必须的,你可以等 h 索引好了之后再试试么?
边索引只有它作为唯一查询条件的时候才需要,如果拓展的时候,走的扫的是边数据,不需要单独建立索引的
system
关闭
2021 年12 月 3 日 03:41
9
此话题已在最后回复的 7 天后被自动关闭。不再允许新回复。