Simplified test case - resolves #943

This commit is contained in:
Andrew Kane
2026-01-05 12:42:14 -08:00
parent df2c3d301f
commit c9875f5150

View File

@@ -16,29 +16,19 @@ $node->safe_psql("postgres",
"INSERT INTO tst SELECT i, ARRAY[random(), random(), random()] FROM generate_series(1, 100000) i;" "INSERT INTO tst SELECT i, ARRAY[random(), random(), random()] FROM generate_series(1, 100000) i;"
); );
# Check each index type # Add index
my @operators = ("<->", "<#>", "<=>"); $node->safe_psql("postgres", "CREATE INDEX ON tst USING ivfflat (v vector_l2_ops);");
my @opclasses = ("vector_l2_ops", "vector_ip_ops", "vector_cosine_ops");
for my $i (0 .. $#operators) # Test 100% recall
for (1 .. 20)
{ {
my $operator = $operators[$i]; my $id = int(rand() * 100000);
my $opclass = $opclasses[$i]; my $query = $node->safe_psql("postgres", "SELECT v FROM tst WHERE i = $id;");
my $res = $node->safe_psql("postgres", qq(
# Add index SET enable_seqscan = off;
$node->safe_psql("postgres", "CREATE INDEX ON tst USING ivfflat (v $opclass);"); SELECT v FROM tst ORDER BY v <-> '$query' LIMIT 1;
));
# Test 100% recall is($res, $query);
for (1 .. 20)
{
my $id = int(rand() * 100000);
my $query = $node->safe_psql("postgres", "SELECT v FROM tst WHERE i = $id;");
my $res = $node->safe_psql("postgres", qq(
SET enable_seqscan = off;
SELECT v FROM tst ORDER BY v <-> '$query' LIMIT 1;
));
is($res, $query);
}
} }
done_testing(); done_testing();