From 158d9340bca5796d8f98182e5a65356bac676b74 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sat, 28 Sep 2024 14:50:23 -0700 Subject: [PATCH] Added distance filters to cost tests [skip ci] --- test/t/039_hnsw_cost.pl | 7 ++++++- test/t/040_ivfflat_cost.pl | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/test/t/039_hnsw_cost.pl b/test/t/039_hnsw_cost.pl index dad50cc..a26c09a 100644 --- a/test/t/039_hnsw_cost.pl +++ b/test/t/039_hnsw_cost.pl @@ -17,7 +17,7 @@ $node->safe_psql("postgres", "CREATE EXTENSION vector;"); for my $dim (@dims) { my $array_sql = join(",", ('random()') x $dim); - my $n = $dim == 384 ? 2000 : 1000; + my $n = $dim == 384 ? 3000 : 1000; # Create table and index $node->safe_psql("postgres", "CREATE TABLE tst (i int4, v vector($dim));"); @@ -40,6 +40,11 @@ for my $dim (@dims) )); like($explain, qr/Index Scan using idx/); + $explain = $node->safe_psql("postgres", qq( + EXPLAIN ANALYZE SELECT i FROM tst WHERE v <-> '$query' < 1 ORDER BY v <-> '$query' LIMIT $limit; + )); + like($explain, qr/Index Scan using idx/); + $node->safe_psql("postgres", "DROP TABLE tst;"); } diff --git a/test/t/040_ivfflat_cost.pl b/test/t/040_ivfflat_cost.pl index 2f6fbf9..1c311a3 100644 --- a/test/t/040_ivfflat_cost.pl +++ b/test/t/040_ivfflat_cost.pl @@ -39,6 +39,11 @@ for my $dim (@dims) )); like($explain, qr/Index Scan using idx/); + $explain = $node->safe_psql("postgres", qq( + EXPLAIN ANALYZE SELECT i FROM tst WHERE v <-> '$query' < 1 ORDER BY v <-> '$query' LIMIT $limit; + )); + like($explain, qr/Index Scan using idx/); + $node->safe_psql("postgres", "DROP TABLE tst;"); }