From bf34ceef7cd815b979598e5c62a97588af1d4adc Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 21 Jan 2024 16:03:22 -0800 Subject: [PATCH] Added more filtering tests --- test/t/018_hnsw_filtering.pl | 13 +++++++++++++ test/t/019_ivfflat_filtering.pl | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/test/t/018_hnsw_filtering.pl b/test/t/018_hnsw_filtering.pl index 074aba5..9e3b657 100644 --- a/test/t/018_hnsw_filtering.pl +++ b/test/t/018_hnsw_filtering.pl @@ -45,6 +45,19 @@ $explain = $node->safe_psql("postgres", qq( )); like($explain, qr/Index Scan using idx/); +# Test attribute filtering with few rows removed comparison +$explain = $node->safe_psql("postgres", qq( + EXPLAIN ANALYZE SELECT i FROM tst WHERE c < 1 ORDER BY v <-> '$query' LIMIT $limit; +)); +like($explain, qr/Index Scan using idx/); + +# Test attribute filtering with many rows removed comparison +$explain = $node->safe_psql("postgres", qq( + EXPLAIN ANALYZE SELECT i FROM tst WHERE c >= 1 ORDER BY v <-> '$query' LIMIT $limit; +)); +# TODO Do not use index +like($explain, qr/Index Scan using idx/); + # Test distance filtering $explain = $node->safe_psql("postgres", qq( EXPLAIN ANALYZE SELECT i FROM tst WHERE v <-> '$query' < 1 ORDER BY v <-> '$query' LIMIT $limit; diff --git a/test/t/019_ivfflat_filtering.pl b/test/t/019_ivfflat_filtering.pl index 1a4c9a1..8a6955e 100644 --- a/test/t/019_ivfflat_filtering.pl +++ b/test/t/019_ivfflat_filtering.pl @@ -45,6 +45,19 @@ $explain = $node->safe_psql("postgres", qq( )); like($explain, qr/Index Scan using idx/); +# Test attribute filtering with few rows removed comparison +$explain = $node->safe_psql("postgres", qq( + EXPLAIN ANALYZE SELECT i FROM tst WHERE c < 1 ORDER BY v <-> '$query' LIMIT $limit; +)); +like($explain, qr/Index Scan using idx/); + +# Test attribute filtering with many rows removed comparison +$explain = $node->safe_psql("postgres", qq( + EXPLAIN ANALYZE SELECT i FROM tst WHERE c >= 1 ORDER BY v <-> '$query' LIMIT $limit; +)); +# TODO Do not use index +like($explain, qr/Index Scan using idx/); + # Test distance filtering $explain = $node->safe_psql("postgres", qq( EXPLAIN ANALYZE SELECT i FROM tst WHERE v <-> '$query' < 1 ORDER BY v <-> '$query' LIMIT $limit;