pgvector.git / summary / log / commit / refs
commit 77b3d1f2a8e08aa6ca2545eddd9fb51796c32ea1
Author: Andrew Kane <andrew@ankane.org>
Date: Wed Sep 25 06:21:34 2024 +0000
Added test for join with attribute filtering [skip ci]
test/t/017_hnsw_filtering.pl | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/test/t/017_hnsw_filtering.pl b/test/t/017_hnsw_filtering.pl
index 4ec8721d..0896d327 100644
--- a/test/t/017_hnsw_filtering.pl
+++ b/test/t/017_hnsw_filtering.pl
@@ -18,12 +18,12 @@ $node->start;
# Create table and index
$node->safe_psql("postgres", "CREATE EXTENSION vector;");
$node->safe_psql("postgres", "CREATE TABLE tst (i int4, v vector($dim), c int4, t text);");
-$node->safe_psql("postgres", "CREATE TABLE cat (i int4 PRIMARY KEY, t text);");
+$node->safe_psql("postgres", "CREATE TABLE cat (i int4 PRIMARY KEY, t text, b boolean);");
$node->safe_psql("postgres",
"INSERT INTO tst SELECT i, ARRAY[$array_sql], i % $nc, 'test ' || i FROM generate_series(1, 10000) i;"
);
$node->safe_psql("postgres",
- "INSERT INTO cat SELECT i, 'cat ' || i FROM generate_series(1, $nc) i;"
+ "INSERT INTO cat SELECT i, 'cat ' || i, i % 5 = 0 FROM generate_series(1, $nc) i;"
);
$node->safe_psql("postgres", "CREATE INDEX idx ON tst USING hnsw (v vector_l2_ops);");
$node->safe_psql("postgres", "ANALYZE tst;");
@@ -106,6 +106,12 @@ $explain = $node->safe_psql("postgres", qq(
));
like($explain, qr/Index Scan using idx/);
+# Test join with attribute filtering
+$explain = $node->safe_psql("postgres", qq(
+ EXPLAIN ANALYZE SELECT cat.t FROM cat INNER JOIN tst ON cat.i = tst.c WHERE cat.b = 't' ORDER BY v <-> '$query' LIMIT $limit;
+));
+like($explain, qr/Index Scan using idx/);
+
# Test attribute index
$node->safe_psql("postgres", "CREATE INDEX attribute_idx ON tst (c);");
$explain = $node->safe_psql("postgres", qq(
[parent: ecd073872879]