mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-11 23:26:55 +08:00
Improved test
This commit is contained in:
@@ -11,7 +11,7 @@ my $limit = 20;
|
|||||||
|
|
||||||
sub test_recall
|
sub test_recall
|
||||||
{
|
{
|
||||||
my ($min) = @_;
|
my ($min, $ef_search, $test_name) = @_;
|
||||||
my $correct = 0;
|
my $correct = 0;
|
||||||
my $total = 0;
|
my $total = 0;
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ sub test_recall
|
|||||||
{
|
{
|
||||||
my $actual = $node->safe_psql("postgres", qq(
|
my $actual = $node->safe_psql("postgres", qq(
|
||||||
SET enable_seqscan = off;
|
SET enable_seqscan = off;
|
||||||
SET hnsw.ef_search = $limit;
|
SET hnsw.ef_search = $ef_search;
|
||||||
SELECT i FROM tst ORDER BY v <-> '$queries[$i]' LIMIT $limit;
|
SELECT i FROM tst ORDER BY v <-> '$queries[$i]' LIMIT $limit;
|
||||||
));
|
));
|
||||||
my @actual_ids = split("\n", $actual);
|
my @actual_ids = split("\n", $actual);
|
||||||
@@ -43,7 +43,7 @@ sub test_recall
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmp_ok($correct / $total, ">=", $min);
|
cmp_ok($correct / $total, ">=", $min, $test_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Initialize node
|
# Initialize node
|
||||||
@@ -63,7 +63,7 @@ $node->safe_psql("postgres",
|
|||||||
$node->safe_psql("postgres", "CREATE INDEX ON tst USING hnsw (v vector_l2_ops);");
|
$node->safe_psql("postgres", "CREATE INDEX ON tst USING hnsw (v vector_l2_ops);");
|
||||||
|
|
||||||
# Delete data
|
# Delete data
|
||||||
$node->safe_psql("postgres", "DELETE FROM tst WHERE i % 2 = 0;");
|
$node->safe_psql("postgres", "DELETE FROM tst WHERE i > 5000;");
|
||||||
|
|
||||||
# Generate queries
|
# Generate queries
|
||||||
for (1 .. 20)
|
for (1 .. 20)
|
||||||
@@ -85,10 +85,11 @@ foreach (@queries)
|
|||||||
push(@expected, $res);
|
push(@expected, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
test_recall(0.45);
|
test_recall(0.40, $limit, "before vacuum");
|
||||||
|
test_recall(0.99, 60, "before vacuum");
|
||||||
|
|
||||||
$node->safe_psql("postgres", "VACUUM tst;");
|
$node->safe_psql("postgres", "VACUUM tst;");
|
||||||
|
|
||||||
test_recall(0.99);
|
test_recall(0.99, $limit, "after vacuum");
|
||||||
|
|
||||||
done_testing();
|
done_testing();
|
||||||
|
|||||||
Reference in New Issue
Block a user