pgvector.git / summary / log / commit / refs
commit ca71ef7a518cb480e2d053dafd9273491799ce27
Author: Andrew Kane <andrew@ankane.org>
Date: Mon Jan 22 02:08:16 2024 +0000
Added analyze to filtering tests
test/t/018_hnsw_filtering.pl | 7 ++++---
test/t/019_ivfflat_filtering.pl | 12 +++++++-----
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/test/t/018_hnsw_filtering.pl b/test/t/018_hnsw_filtering.pl
index cc96a2f7..f85f5cf7 100644
--- a/test/t/018_hnsw_filtering.pl
+++ b/test/t/018_hnsw_filtering.pl
@@ -22,6 +22,7 @@ $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", "CREATE INDEX idx ON tst USING hnsw (v vector_l2_ops);");
+$node->safe_psql("postgres", "ANALYZE tst;");
# Generate query
my @r = ();
@@ -68,8 +69,7 @@ like($explain, qr/Index Scan using idx/);
$explain = $node->safe_psql("postgres", qq(
EXPLAIN ANALYZE SELECT i FROM tst WHERE t LIKE '%%other%%' ORDER BY v <-> '$query' LIMIT $limit;
));
-# TODO Do not use index
-like($explain, qr/Index Scan using idx/);
+like($explain, qr/Seq Scan/);
# Test distance filtering
$explain = $node->safe_psql("postgres", qq(
@@ -101,7 +101,8 @@ $node->safe_psql("postgres", "CREATE INDEX attribute_idx ON tst (c);");
$explain = $node->safe_psql("postgres", qq(
EXPLAIN ANALYZE SELECT i FROM tst WHERE c = $c ORDER BY v <-> '$query' LIMIT $limit;
));
-like($explain, qr/Bitmap Index Scan on attribute_idx/);
+# TODO Use attribute index
+like($explain, qr/Index Scan using idx/);
# Test partial index
$node->safe_psql("postgres", "CREATE INDEX partial_idx ON tst USING hnsw (v vector_l2_ops) WHERE (c = $c);");
diff --git a/test/t/019_ivfflat_filtering.pl b/test/t/019_ivfflat_filtering.pl
index 8f01bf4a..dd693ca7 100644
--- a/test/t/019_ivfflat_filtering.pl
+++ b/test/t/019_ivfflat_filtering.pl
@@ -19,9 +19,10 @@ $node->start;
$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",
- "INSERT INTO tst SELECT i, ARRAY[$array_sql], i % $nc FROM generate_series(1, 10000) i;"
+ "INSERT INTO tst SELECT i, ARRAY[$array_sql], i % $nc, 'test ' || i FROM generate_series(1, 10000) i;"
);
$node->safe_psql("postgres", "CREATE INDEX idx ON tst USING ivfflat (v vector_l2_ops) WITH (lists = 100);");
+$node->safe_psql("postgres", "ANALYZE tst;");
# Generate query
my @r = ();
@@ -68,8 +69,7 @@ like($explain, qr/Index Scan using idx/);
$explain = $node->safe_psql("postgres", qq(
EXPLAIN ANALYZE SELECT i FROM tst WHERE t LIKE '%%other%%' ORDER BY v <-> '$query' LIMIT $limit;
));
-# TODO Do not use index
-like($explain, qr/Index Scan using idx/);
+like($explain, qr/Seq Scan/);
# Test distance filtering
$explain = $node->safe_psql("postgres", qq(
@@ -102,13 +102,15 @@ $node->safe_psql("postgres", "CREATE INDEX attribute_idx ON tst (c);");
$explain = $node->safe_psql("postgres", qq(
EXPLAIN ANALYZE SELECT i FROM tst WHERE c = $c ORDER BY v <-> '$query' LIMIT $limit;
));
-like($explain, qr/Bitmap Index Scan on attribute_idx/);
+# TODO Use attribute index
+like($explain, qr/Index Scan using idx/);
# Test partial index
$node->safe_psql("postgres", "CREATE INDEX partial_idx ON tst USING ivfflat (v vector_l2_ops) WITH (lists = 5) WHERE (c = $c);");
$explain = $node->safe_psql("postgres", qq(
EXPLAIN ANALYZE SELECT i FROM tst WHERE c = $c ORDER BY v <-> '$query' LIMIT $limit;
));
-like($explain, qr/Index Scan using partial_idx/);
+# TODO Use partial index
+like($explain, qr/Index Scan using idx/);
done_testing();
[parent: 8bd01ff006f8]