forked from vesoft-inc/nebula
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndexSelecting.feature
141 lines (139 loc) · 6.86 KB
/
IndexSelecting.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Copyright (c) 2021 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License.
Feature: Index selecting for match statement
Background: Prepare a new space
Given an empty graph
And create a space with following options:
| partition_num | 9 |
| replica_factor | 1 |
| vid_type | FIXED_STRING(30) |
| charset | utf8 |
| collate | utf8_bin |
And having executed:
"""
CREATE tag player(name string, age int, score int, gender bool);
"""
And having executed:
"""
INSERT VERTEX player(name, age, score, gender) VALUES "Tim Duncan":("Tim Duncan", 42, 28, true),"Yao Ming":("Yao Ming", 38, 23, true),"Nneka Ogwumike":("Nneka Ogwumike", 35, 13, false);
"""
And having executed:
"""
create tag index player_index on player();
create tag index player_name_index on player(name(8));
create tag index player_age_name_index on player(age,name(8));
"""
And wait 3 seconds
Scenario: Test Index selecting
When submit a job:
"""
rebuild tag index player_index;
"""
Then wait the job to finish
When submit a job:
"""
rebuild tag index player_name_index;
"""
Then wait the job to finish
When submit a job:
"""
rebuild tag index player_age_name_index;
"""
Then wait the job to finish
# Prefix Index
When profiling query:
"""
MATCH (v:player {name: "Yao Ming"}) RETURN v.name AS name
"""
Then the result should be, in any order, with relax comparison:
| name |
| "Yao Ming" |
And the execution plan should be:
| id | name | dependencies | operator info |
| 6 | Project | 2 | |
| 2 | AppendVertices | 5 | |
| 5 | IndexScan | 0 | {"indexCtx": {"columnHints":{"scanType":"PREFIX"}}} |
| 0 | Start | | |
When profiling query:
"""
MATCH (v:player) WHERE v.name == "Tim Duncan" and v.name < "Zom" RETURN v.name AS name
"""
Then the result should be, in any order, with relax comparison:
| name |
| "Tim Duncan" |
And the execution plan should be:
| id | name | dependencies | operator info |
| 9 | Project | 7 | |
| 7 | Filter | 2 | |
| 2 | AppendVertices | 6 | |
| 6 | IndexScan | 0 | {"indexCtx": {"columnHints":{"scanType":"PREFIX"}}} |
| 0 | Start | | |
When profiling query:
"""
MATCH (v:player) WHERE v.name=="Tim Duncan" and v.age>4 and v.name>"A" RETURN v.name AS name
"""
Then the result should be, in any order, with relax comparison:
| name |
| "Tim Duncan" |
And the execution plan should be:
| id | name | dependencies | operator info |
| 9 | Project | 7 | |
| 7 | Filter | 2 | |
| 2 | AppendVertices | 6 | |
| 6 | IndexScan | 0 | {"indexCtx": {"columnHints":{"scanType":"PREFIX"}}} |
| 0 | Start | | |
When profiling query:
"""
MATCH (v:player{name:"Tim Duncan"}) WHERE v.name < "Zom" RETURN v.name AS name
"""
Then the result should be, in any order, with relax comparison:
| name |
| "Tim Duncan" |
And the execution plan should be:
| id | name | dependencies | operator info |
| 9 | Project | 7 | |
| 7 | Filter | 2 | |
| 2 | AppendVertices | 6 | |
| 6 | IndexScan | 0 | {"indexCtx": {"columnHints":{"scanType":"PREFIX"}}} |
| 0 | Start | | |
# Range Index
When profiling query:
"""
MATCH (v:player) WHERE v.name > "Tim" and v.name < "Zom" RETURN v.name AS name
"""
Then the result should be, in any order, with relax comparison:
| name |
| "Yao Ming" |
| "Tim Duncan" |
And the execution plan should be:
| id | name | dependencies | operator info |
| 9 | Project | 7 | |
| 7 | Filter | 2 | |
| 2 | AppendVertices | 6 | |
| 6 | IndexScan | 0 | {"indexCtx": {"columnHints":{"scanType":"RANGE"}}} |
| 0 | Start | | |
# Degeneration to FullScan Index
When executing query:
"""
MATCH (v:player) WHERE v.score < 20 RETURN v.name AS name
"""
Then the result should be, in any order, with relax comparison:
| name |
| "Nneka Ogwumike" |
# Degeneration to Prefix Index
When profiling query:
"""
MATCH (v:player) WHERE v.name == "Tim Duncan" and v.score == 28 RETURN v.name AS name
"""
Then the result should be, in any order, with relax comparison:
| name |
| "Tim Duncan" |
And the execution plan should be:
| id | name | dependencies | operator info |
| 9 | Project | 7 | |
| 7 | Filter | 2 | |
| 2 | AppendVertices | 6 | |
| 6 | IndexScan | 0 | {"indexCtx": {"columnHints":{"scanType":"PREFIX"}}} |
| 0 | Start | | |
Then drop the used space