@@ -50,23 +50,23 @@ id select_type table partitions type possible_keys key key_len ref rows filtered
50501 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using filesort
5151
5252
53- 3. Verify that the optimizer does not choose the vector index without
53+ 3. Verify that the optimizer DOES choose the vector index EVEN without
5454the LIMIT clause for the above 3 cases
5555
5656Case A. SELECT *
5757explain select * from t1 order by FB_VECTOR_L2(vector1, '[2, 1, 1]');
5858id select_type table partitions type possible_keys key key_len ref rows filtered Extra
59- 1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using filesort
59+ 1 SIMPLE t1 NULL index NULL vector_key_1 65536 NULL 1 100.00 NULL
6060
6161Case B. SELECT <vector index field>
6262explain select vector1 from t1 order by FB_VECTOR_L2(vector1, '[2, 1, 1]');
6363id select_type table partitions type possible_keys key key_len ref rows filtered Extra
64- 1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using filesort
64+ 1 SIMPLE t1 NULL index NULL vector_key_1 65536 NULL 1 100.00 NULL
6565
6666Case C. SELECT <primary key field>
6767explain select id from t1 order by FB_VECTOR_L2(vector1, '[2, 1, 1]');
6868id select_type table partitions type possible_keys key key_len ref rows filtered Extra
69- 1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using filesort
69+ 1 SIMPLE t1 NULL index NULL vector_key_1 65536 NULL 1 100.00 NULL
7070
7171
72724. Verify that the optimizer chooses the vector index for an ORDER BY with
@@ -126,25 +126,34 @@ id select_type table partitions type possible_keys key key_len ref rows filtered
1261261 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using filesort
127127
128128
129- 6 . Other scenarios - Vector dist fn as part of SELECT fields
129+ 7 . Other scenarios - Vector dist fn as part of SELECT fields
130130
131131Case A. SELECT *
132132explain select *, FB_VECTOR_L2(vector1, '[2, 1, 1]') as dis from t1 order by dis limit 2;
133133id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1341341 SIMPLE t1 NULL index NULL vector_key_1 65536 NULL 1 100.00 NULL
135+ explain select *, FB_VECTOR_L2(vector1, '[2, 1, 1]') as dis from t1 having dis < 7 order by dis limit 2;
136+ id select_type table partitions type possible_keys key key_len ref rows filtered Extra
137+ 1 SIMPLE t1 NULL index NULL vector_key_1 65536 NULL 1 100.00 Using where
135138
136139Case B. SELECT <vector index field>
137140explain select vector1, FB_VECTOR_L2(vector1, '[2, 1, 1]') as dis from t1 order by dis limit 2;
138141id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1391421 SIMPLE t1 NULL index NULL vector_key_1 65536 NULL 1 100.00 NULL
143+ explain select vector1, FB_VECTOR_L2(vector1, '[2, 1, 1]') as dis from t1 having dis < 7 order by dis limit 2;
144+ id select_type table partitions type possible_keys key key_len ref rows filtered Extra
145+ 1 SIMPLE t1 NULL index NULL vector_key_1 65536 NULL 1 100.00 Using where
140146
141147Case C. SELECT <primary key field>
142148explain select id, FB_VECTOR_L2(vector1, '[2, 1, 1]') as dis from t1 order by dis limit 2;
143149id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1441501 SIMPLE t1 NULL index NULL vector_key_1 65536 NULL 1 100.00 NULL
151+ explain select id, FB_VECTOR_L2(vector1, '[2, 1, 1]') as dis from t1 having dis < 7 order by dis limit 2;
152+ id select_type table partitions type possible_keys key key_len ref rows filtered Extra
153+ 1 SIMPLE t1 NULL index NULL vector_key_1 65536 NULL 1 100.00 Using where
145154
146155
147- 7 . Test ORDER BY and LIMIT pushdown to MyRocks by looking at output of Iterators
156+ 8 . Test ORDER BY and LIMIT pushdown to MyRocks by looking at output of Iterators
148157
149158Case A. SELECT *
150159select * from t1 order by FB_VECTOR_L2(vector1, '[1, 2, 3]') limit 2;
0 commit comments