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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
flex --header-file=lex.yy.h lex_sql.l
bison -d -b yacc_sql yacc_sql.y
cd /root/gitee/miniob-2022/build/bin
./observer -f /root/gitee/miniob-2022/etc/observer.ini
/root/gitee/miniob-2022/build/bin/obclient
CREATE TABLE multi_index(id int, col1 int, col2 float, col3 char, col4 date, col5 int, col6 int);
CREATE INDEX i_1_12 ON multi_index(col1,col2);
CREATE INDEX i_1_345 ON multi_index(col3, col4, col5);
CREATE INDEX i_1_56 ON multi_index(col5, col6);
CREATE INDEX i_1_456 ON multi_index(col4, col5, col6);
SELECT * FROM multi_index;
ID | COL1 | COL2 | COL3 | COL4 | COL5 | COL6
2. MULTI INDEX OF NON-EMPTY TABLE
CREATE TABLE multi_index2(id int, col1 int, col2 float, col3 char, col4 date, col5 int, col6 int);
INSERT INTO multi_index2 VALUES (1, 1, 11.2, 'a', '2021-01-02', 1, 1);
INSERT INTO multi_index2 VALUES (2, 1, 16.2, 'x', '2021-01-02', 1, 61);
INSERT INTO multi_index2 VALUES (3, 1, 11.6, 'h', '2023-01-02', 10, 17);
CREATE INDEX i_2_12 ON multi_index2(col1,col2);
SUCCESS
CREATE INDEX i_2_345 ON multi_index2(col3, col4, col5);
SUCCESS
CREATE INDEX i_2_56 ON multi_index2(col5, col6);
SUCCESS
CREATE INDEX i_2_456 ON multi_index2(col4, col5, col6);
SUCCESS
SELECT * FROM multi_index2;
1 | 1 | 11.2 | A | 2021-01-02 | 1 | 1
2 | 1 | 16.2 | X | 2021-01-02 | 1 | 61
3 | 1 | 11.6 | H | 2023-01-02 | 10 | 17
ID | COL1 | COL2 | COL3 | COL4 | COL5 | COL6
3. INFLUENCE OF INSERTING
CREATE TABLE multi_index3(id int, col1 int, col2 float, col3 char, col4 date, col5 int, col6 int);
CREATE INDEX i_3_i1 ON multi_index3(id,col1);
INSERT INTO multi_index3 VALUES (1, 1, 11.2, 'a', '2021-01-02', 1, 1);
SUCCESS
INSERT INTO multi_index3 VALUES (1, 1, 11.2, 'a', '2021-01-02', 1, 1);
SUCCESS
SELECT * FROM multi_index3;
1 | 1 | 11.2 | A | 2021-01-02 | 1 | 1
1 | 1 | 11.2 | A | 2021-01-02 | 1 | 1
ID | COL1 | COL2 | COL3 | COL4 | COL5 | COL6
CREATE INDEX i_3_14 ON multi_index3(col1,col4);
SUCCESS
INSERT INTO multi_index3 VALUES (2, 1, 16.2, 'x', '2021-01-02', 1, 61);
SUCCESS
INSERT INTO multi_index3 VALUES (3, 1, 11.6, 'h', '2023-01-02', 10, 17);
SUCCESS
INSERT INTO multi_index3 VALUES (4, 2, 12.2, 'e', '2022-01-04', 13, 10);
SUCCESS
INSERT INTO multi_index3 VALUES (5, 3, 14.2, 'd', '2020-04-02', 12, 2);
SUCCESS
SELECT * FROM multi_index3;
1 | 1 | 11.2 | A | 2021-01-02 | 1 | 1
1 | 1 | 11.2 | A | 2021-01-02 | 1 | 1
2 | 1 | 16.2 | X | 2021-01-02 | 1 | 61
3 | 1 | 11.6 | H | 2023-01-02 | 10 | 17
4 | 2 | 12.2 | E | 2022-01-04 | 13 | 10
5 | 3 | 14.2 | D | 2020-04-02 | 12 | 2
ID | COL1 | COL2 | COL3 | COL4 | COL5 | COL6
4. QUERY WITH INDEXS
SELECT * FROM multi_index3 WHERE id = 1;
1 | 1 | 11.2 | A | 2021-01-02 | 1 | 1
1 | 1 | 11.2 | A | 2021-01-02 | 1 | 1
ID | COL1 | COL2 | COL3 | COL4 | COL5 | COL6
SELECT * FROM multi_index3 WHERE col1 > 1 and col4 = '2021-01-02';
ID | COL1 | COL2 | COL3 | COL4 | COL5 | COL6
SELECT * FROM multi_index3 WHERE col1 <> 1 and col4 >= '2021-01-02';
4 | 2 | 12.2 | E | 2022-01-04 | 13 | 10
ID | COL1 | COL2 | COL3 | COL4 | COL5 | COL6
SELECT * FROM multi_index3 WHERE col2 < 15.0 and col4 <> '2021-01-02';
3 | 1 | 11.6 | H | 2023-01-02 | 10 | 17
4 | 2 | 12.2 | E | 2022-01-04 | 13 | 10
5 | 3 | 14.2 | D | 2020-04-02 | 12 | 2
ID | COL1 | COL2 | COL3 | COL4 | COL5 | COL6
5. INFLUENCE OF DELETING
DELETE FROM multi_index3 WHERE id = 1;
SUCCESS
DELETE FROM multi_index3 WHERE id = 61;
SUCCESS
SELECT * FROM multi_index3;
2 | 1 | 16.2 | X | 2021-01-02 | 1 | 61
3 | 1 | 11.6 | H | 2023-01-02 | 10 | 17
4 | 2 | 12.2 | E | 2022-01-04 | 13 | 10
5 | 3 | 14.2 | D | 2020-04-02 | 12 | 2
ID | COL1 | COL2 | COL3 | COL4 | COL5 | COL6
DELETE FROM multi_index3 WHERE col3 = 'x';
SUCCESS
SELECT * FROM multi_index3;
3 | 1 | 11.6 | H | 2023-01-02 | 10 | 17
4 | 2 | 12.2 | E | 2022-01-04 | 13 | 10
5 | 3 | 14.2 | D | 2020-04-02 | 12 | 2
ID | COL1 | COL2 | COL3 | COL4 | COL5 | COL6
DELETE FROM multi_index3 WHERE id = 4 and col1 = 1;
SUCCESS
DELETE FROM multi_index3 WHERE id = 90 and col1 = 13;
SUCCESS
DELETE FROM multi_index3 WHERE id = 90 and col1 = 1;
SUCCESS
DELETE FROM multi_index3 WHERE id = 4 and col1 = 13;
SUCCESS
DELETE FROM multi_index3 WHERE id = 3 and col1 = 1;
SUCCESS
DELETE FROM multi_index3 WHERE id = 3 and col1 = 1;
SUCCESS
SELECT * FROM multi_index3;
4 | 2 | 12.2 | E | 2022-01-04 | 13 | 10
5 | 3 | 14.2 | D | 2020-04-02 | 12 | 2
ID | COL1 | COL2 | COL3 | COL4 | COL5 | COL6
INSERT INTO multi_index3 VALUES (1, 1, 11.2, 'a', '2021-01-02', 1, 1);
SUCCESS
INSERT INTO multi_index3 VALUES (2, 1, 11.2, 'x', '2021-01-02', 1, 61);
SUCCESS
INSERT INTO multi_index3 VALUES (3, 1, 11.2, 'h', '2023-01-02', 10, 17);
SUCCESS
SELECT * FROM multi_index3;
1 | 1 | 11.2 | A | 2021-01-02 | 1 | 1
2 | 1 | 11.2 | X | 2021-01-02 | 1 | 61
3 | 1 | 11.2 | H | 2023-01-02 | 10 | 17
4 | 2 | 12.2 | E | 2022-01-04 | 13 | 10
5 | 3 | 14.2 | D | 2020-04-02 | 12 | 2
ID | COL1 | COL2 | COL3 | COL4 | COL5 | COL6
6. INFLUENCE OF UPDATING
UPDATE multi_index3 SET col6=49 where id=2;
SUCCESS
UPDATE multi_index3 SET col4='1999-02-01' where id=2;
SUCCESS
UPDATE multi_index3 SET col1=2 where id=2;
SUCCESS
UPDATE multi_index3 SET col1=5 where col6=49;
SUCCESS
SELECT * FROM multi_index3;
1 | 1 | 11.2 | A | 2021-01-02 | 1 | 1
2 | 5 | 11.2 | X | 1999-02-01 | 1 | 49
3 | 1 | 11.2 | H | 2023-01-02 | 10 | 17
4 | 2 | 12.2 | E | 2022-01-04 | 13 | 10
5 | 3 | 14.2 | D | 2020-04-02 | 12 | 2
ID | COL1 | COL2 | COL3 | COL4 | COL5 | COL6
7. INFLUENCE OF DROPPING TABLE
DROP table multi_index;
SUCCESS
8. ERROR
CREATE TABLE multi_index4(id int, col1 int, col2 float, col3 char, col4 date, col5 int, col6 int);
SUCCESS
CREATE INDEX i_4_i7 ON multi_index4(id,col7);
FAILURE
CREATE INDEX i_4_78 ON multi_index4(col7,col8);
FAILURE
CREATE INDEX i_4_i78 ON multi_index4(id,col7,col8);
FAILURE
|