Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update composite property indexes #1118

Merged
merged 3 commits into from
Nov 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,34 @@ nebula> CREATE TAG INDEX player_index_1 on player(name(10), age);
!!! caution

不支持跨Tag或Edge type创建复合索引。

!!! note

使用复合属性索引时,遵循"最左匹配原则",必须从复合属性索引的最左侧开始匹配。
<!--
需要注意的是:

- 如果`LOOKUP`语句没有匹配复合属性索引,会退化为全表扫描。

- 如果`MATCH`语句没有匹配复合属性索引,会返回报错。

请参见下方示例。

```ngql
# 为标签t的前三个属性创建复合属性索引。
nebula> CREATE TAG INDEX example_index ON TAG t(p1, p2, p3);

# 注意:无法匹配到索引,因为不是从p1开始,会返回找不到有效索引的报错。
nebula> MATCH (v:t) WHERE t.p2 == 2 and t.p3 == 3;

# 注意:无法匹配到索引,但是退化为全表扫描进行查询。
nebula> LOOKUP ON t2 where t.p2 == 2;

# 可以匹配到索引。
nebula> MATCH (v:t) WHERE t.p1 == 1;
# 可以匹配到索引,因为p1和p2是连续的。
nebula> MATCH (v:t) WHERE t.p1 == 1 and t.p2 == 2;
# 可以匹配到索引,因为p1、p2、p3是连续的。
nebula> MATCH (v:t) WHERE t.p1 == 1 and t.p2 == 2 and t.p3 == 3;
```
-->