From 62ffc3641c2e7f7a4ec4c98fd945543da5b48b99 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 24 Sep 2024 23:12:27 -0700 Subject: [PATCH] Added test for join [skip ci] --- test/t/017_hnsw_filtering.pl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/t/017_hnsw_filtering.pl b/test/t/017_hnsw_filtering.pl index 249b32d..3d4feff 100644 --- a/test/t/017_hnsw_filtering.pl +++ b/test/t/017_hnsw_filtering.pl @@ -18,9 +18,13 @@ $node->start; # Create table and index $node->safe_psql("postgres", "CREATE EXTENSION vector;"); $node->safe_psql("postgres", "CREATE TABLE tst (i int4, v vector($dim), c int4, t text);"); +$node->safe_psql("postgres", "CREATE TABLE cat (i int4 PRIMARY KEY, t text);"); $node->safe_psql("postgres", "INSERT INTO tst SELECT i, ARRAY[$array_sql], i % $nc, 'test ' || i FROM generate_series(1, 10000) i;" ); +$node->safe_psql("postgres", + "INSERT INTO cat SELECT i, 'cat ' || i FROM generate_series(1, $nc) i;" +); $node->safe_psql("postgres", "CREATE INDEX idx ON tst USING hnsw (v vector_l2_ops);"); $node->safe_psql("postgres", "ANALYZE tst;"); @@ -96,6 +100,12 @@ $explain = $node->safe_psql("postgres", qq( )); like($explain, qr/Seq Scan/); +# Test join +$explain = $node->safe_psql("postgres", qq( + EXPLAIN ANALYZE SELECT cat.t FROM cat INNER JOIN tst ON cat.i = tst.i ORDER BY v <-> '$query' LIMIT $limit; +)); +like($explain, qr/Index Scan using idx/); + # Test attribute index $node->safe_psql("postgres", "CREATE INDEX attribute_idx ON tst (c);"); $explain = $node->safe_psql("postgres", qq(