Skip to content

Commit c9875f5

Browse files
committed
Simplified test case - resolves #943
1 parent df2c3d3 commit c9875f5

1 file changed

Lines changed: 11 additions & 21 deletions

File tree

test/t/005_ivfflat_query_recall.pl

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,19 @@
1616
"INSERT INTO tst SELECT i, ARRAY[random(), random(), random()] FROM generate_series(1, 100000) i;"
1717
);
1818

19-
# Check each index type
20-
my @operators = ("<->", "<#>", "<=>");
21-
my @opclasses = ("vector_l2_ops", "vector_ip_ops", "vector_cosine_ops");
19+
# Add index
20+
$node->safe_psql("postgres", "CREATE INDEX ON tst USING ivfflat (v vector_l2_ops);");
2221

23-
for my $i (0 .. $#operators)
22+
# Test 100% recall
23+
for (1 .. 20)
2424
{
25-
my $operator = $operators[$i];
26-
my $opclass = $opclasses[$i];
27-
28-
# Add index
29-
$node->safe_psql("postgres", "CREATE INDEX ON tst USING ivfflat (v $opclass);");
30-
31-
# Test 100% recall
32-
for (1 .. 20)
33-
{
34-
my $id = int(rand() * 100000);
35-
my $query = $node->safe_psql("postgres", "SELECT v FROM tst WHERE i = $id;");
36-
my $res = $node->safe_psql("postgres", qq(
37-
SET enable_seqscan = off;
38-
SELECT v FROM tst ORDER BY v <-> '$query' LIMIT 1;
39-
));
40-
is($res, $query);
41-
}
25+
my $id = int(rand() * 100000);
26+
my $query = $node->safe_psql("postgres", "SELECT v FROM tst WHERE i = $id;");
27+
my $res = $node->safe_psql("postgres", qq(
28+
SET enable_seqscan = off;
29+
SELECT v FROM tst ORDER BY v <-> '$query' LIMIT 1;
30+
));
31+
is($res, $query);
4232
}
4333

4434
done_testing();

0 commit comments

Comments
 (0)