Adjust index scan cost based on selectivity [skip ci]

This commit is contained in:
Andrew Kane
2024-09-22 20:23:56 -07:00
parent 97cf990e0f
commit 61b2ddeb86
2 changed files with 40 additions and 6 deletions

View File

@@ -5,7 +5,7 @@ use PostgreSQL::Test::Utils;
use Test::More;
my $dim = 3;
my $nc = 50;
my $nc = 100;
my $limit = 20;
my $array_sql = join(",", ('random()') x $dim);
@@ -102,15 +102,13 @@ $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;
));
# TODO Use attribute index
like($explain, qr/Index Scan using idx/);
like($explain, qr/Index Scan on attribute_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;
));
# TODO Use partial index
like($explain, qr/Index Scan using idx/);
like($explain, qr/Index Scan using partial_idx/);
done_testing();