-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: cutecutecat <[email protected]>
- Loading branch information
1 parent
7e5a584
commit b0652e7
Showing
6 changed files
with
160 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
# TODO: Some tests are disabled due to unimplemented types: sparse vector and f16 vector | ||
|
||
statement ok | ||
CREATE TABLE t (val0 vector(3)); | ||
|
||
statement ok | ||
INSERT INTO t (val0) | ||
SELECT | ||
ARRAY[random(), random(), random()]::real[]::vector | ||
FROM generate_series(1, 10000); | ||
|
||
statement ok | ||
CREATE INDEX ind0 ON t USING vchordrq (val0 vector_l2_ops); | ||
|
||
# statement ok | ||
# CREATE INDEX ind1 ON t USING vchordrq (val1 halfvec_dot_ops); | ||
|
||
# 1 vector key + 1 corresponding order_by key + sphere style | ||
query I | ||
EXPLAIN (COSTS FALSE, TIMING FALSE) | ||
SELECT val0 FROM t WHERE val0 <<->> sphere('[0, 0, 0]'::vector, 1) ORDER BY val0 <-> '[0, 0, 0]'; | ||
---- | ||
Index Scan using ind0 on t | ||
Index Cond: (val0 <<->> '("[0,0,0]",1)'::sphere_vector) | ||
Order By: (val0 <-> '[0,0,0]'::vector) | ||
|
||
# 1 vector key + 0 order_by key + original style | ||
query I | ||
EXPLAIN (COSTS FALSE, TIMING FALSE) | ||
SELECT val0 FROM t WHERE val0 <-> '[0, 0, 0]' < 1; | ||
---- | ||
Seq Scan on t | ||
Filter: ((val0 <-> '[0,0,0]'::vector) < '1'::double precision) | ||
|
||
# 1 vector key + 0 order_by key + sphere style | ||
query I | ||
EXPLAIN (COSTS FALSE, TIMING FALSE) | ||
SELECT val0 FROM t WHERE val0 <<->> sphere('[0, 0, 0]'::vector, 1); | ||
---- | ||
Index Scan using ind0 on t | ||
Index Cond: (val0 <<->> '("[0,0,0]",1)'::sphere_vector) | ||
|
||
# 0 vector key + 1 order_by key | ||
query I | ||
EXPLAIN (COSTS FALSE, TIMING FALSE) | ||
SELECT val0 FROM t ORDER BY val0 <-> '[0, 0, 0]'; | ||
---- | ||
Index Scan using ind0 on t | ||
Order By: (val0 <-> '[0,0,0]'::vector) | ||
|
||
# 2 vector key(1 of them is corresponding) + 1 order_by key + original style | ||
# query I | ||
# EXPLAIN (COSTS FALSE, TIMING FALSE) | ||
# SELECT val0 FROM t WHERE val0 <-> '[0, 0, 0]' < 1 | ||
# AND val1 <#> '[0, 0, 0]' < 1 | ||
# ORDER BY val0 <-> '[0, 0, 0]'; | ||
# ---- | ||
# Index Scan using ind0 on t | ||
# Order By: (val0 <-> '[0,0,0]'::vector) | ||
# Filter: (((val0 <-> '[0,0,0]'::vector) < '1'::double precision) AND ((val1 <#> '[0,0,0]'::halfvec) < '1'::double precision)) | ||
|
||
# 2 vector key(1 of them is corresponding) + 1 order_by key + sphere style | ||
# query I | ||
# EXPLAIN (COSTS FALSE, TIMING FALSE) | ||
# SELECT val0 FROM t WHERE val0 <<->> sphere('[0, 0, 0]'::vector, 1) | ||
# AND val1 <<#>> sphere('[0, 0, 0]'::halfvec, 1) | ||
# ORDER BY val0 <-> '[0, 0, 0]'; | ||
# ---- | ||
# Index Scan using ind0 on t | ||
# Index Cond: (val0 <<->> '("[0,0,0]",1)'::sphere_vector) | ||
# Order By: (val0 <-> '[0,0,0]'::vector) | ||
# Filter: (val1 <<#>> '("[0,0,0]",1)'::sphere_vecf16) | ||
|
||
# 2 vector key(none of them is corresponding) + 1 order_by key + sphere style | ||
# query I | ||
# EXPLAIN (COSTS FALSE, TIMING FALSE) | ||
# SELECT val0 FROM t WHERE val2 <<->> sphere('{}/3'::svector, 1) | ||
# AND val1 <<#>> sphere('[0, 0, 0]'::halfvec, 1) | ||
# ORDER BY val0 <-> '[0, 0, 0]'; | ||
# ---- | ||
# Index Scan using ind0 on t | ||
# Order By: (val0 <-> '[0,0,0]'::vector) | ||
# Filter: ((val2 <<->> '({}/3,1)'::sphere_svector) AND (val1 <<#>> '("[0,0,0]",1)'::sphere_vecf16)) | ||
|
||
# 2 vector keys(both indexed) + 0 order_by key + sphere style | ||
# query I | ||
# EXPLAIN (COSTS FALSE, TIMING FALSE) | ||
# SELECT val0 FROM t WHERE val0 <<->> sphere('[0, 0, 0]'::vector, 1) | ||
# AND val1 <<#>> sphere('[0, 0, 0]'::halfvec, 1); | ||
# ---- | ||
# Index Scan using ind1 on t | ||
# Index Cond: (val1 <<#>> '("[0,0,0]",1)'::sphere_vecf16) | ||
# Filter: (val0 <<->> '("[0,0,0]",1)'::sphere_vector) | ||
|
||
# 2 vector keys(both not indexed) + 0 order_by key + sphere style | ||
# query I | ||
# EXPLAIN (COSTS FALSE, TIMING FALSE) | ||
# SELECT val0 FROM t WHERE val0 <<#>> sphere('[0, 0, 0]'::vector, 1) | ||
# AND val1 <<->> sphere('[0, 0, 0]'::halfvec, 1); | ||
# ---- | ||
# Seq Scan on t | ||
# Filter: ((val0 <<#>> '("[0,0,0]",1)'::sphere_vector) AND (val1 <<->> '("[0,0,0]",1)'::sphere_vecf16)) | ||
|
||
# 2 vector key(1 indexed) + 0 order_by key + sphere style | ||
# query I | ||
# EXPLAIN (COSTS FALSE, TIMING FALSE) | ||
# SELECT val0 FROM t WHERE val0 <<->> sphere('[0, 0, 0]'::vector, 1) | ||
# AND val1 <<->> sphere('[0, 0, 0]'::halfvec, 1); | ||
# ---- | ||
# Index Scan using ind0 on t | ||
# Index Cond: (val0 <<->> '("[0,0,0]",1)'::sphere_vector) | ||
# Filter: (val1 <<->> '("[0,0,0]",1)'::sphere_vecf16) | ||
|
||
# 1 vector key + 1 not corresponding order_by key(operator) + sphere style | ||
query I | ||
EXPLAIN (COSTS FALSE, TIMING FALSE) | ||
SELECT val0 FROM t WHERE val0 <<#>> sphere('[0, 0, 0]'::vector, 1) | ||
ORDER BY val0 <-> '[0, 0, 0]'; | ||
---- | ||
Index Scan using ind0 on t | ||
Order By: (val0 <-> '[0,0,0]'::vector) | ||
Filter: (val0 <<#>> '("[0,0,0]",1)'::sphere_vector) | ||
|
||
# 1 vector key + 1 not corresponding order_by key(variable) + sphere style | ||
# query I | ||
# EXPLAIN (COSTS FALSE, TIMING FALSE) | ||
# SELECT val0 FROM t WHERE val0 <<->> sphere('[0, 0, 0]'::vector, 1) | ||
# ORDER BY val1 <#> '[1, 1, 1]'; | ||
# ---- | ||
# Index Scan using ind1 on t | ||
# Order By: (val1 <#> '[1,1,1]'::halfvec) | ||
# Filter: (val0 <<->> '("[0,0,0]",1)'::sphere_vector) | ||
|
||
# 0 vector key + 0 order_by key(variable) | ||
query I | ||
EXPLAIN (COSTS FALSE, TIMING FALSE) SELECT val0 FROM t; | ||
---- | ||
Seq Scan on t | ||
|
||
statement ok | ||
DROP TABLE t; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters