pgvector.git / summary / log / commit / refs
commit fed60dce78fa6a34ef595465a3b49f85cb8eb143
Author: Andrew Kane <andrew@ankane.org>
Date: Wed Feb 16 01:04:20 2022 +0000
Added tests for lists
test/t/006_lists.pl | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/test/t/006_lists.pl b/test/t/006_lists.pl
new file mode 100644
index 00000000..eeb11aa3
--- /dev/null
+++ b/test/t/006_lists.pl
@@ -0,0 +1,31 @@
+use strict;
+use warnings;
+use PostgresNode;
+use TestLib;
+use Test::More tests => 3;
+
+# Initialize node
+my $node = get_new_node('node');
+$node->init;
+$node->start;
+
+# Create table
+$node->safe_psql("postgres", "CREATE EXTENSION vector;");
+$node->safe_psql("postgres", "CREATE TABLE tst (v vector(3));");
+$node->safe_psql("postgres",
+ "INSERT INTO tst SELECT ARRAY[random(), random(), random()] FROM generate_series(1, 100000) i;"
+);
+
+$node->safe_psql("postgres", "CREATE INDEX lists50 ON tst USING ivfflat (v) WITH (lists = 50);");
+$node->safe_psql("postgres", "CREATE INDEX lists100 ON tst USING ivfflat (v) WITH (lists = 100);");
+
+# Test prefers more lists
+my $res = $node->safe_psql("postgres", "EXPLAIN SELECT v FROM tst ORDER BY v <-> '[0.5,0.5,0.5]' LIMIT 10;");
+like($res, qr/lists100/);
+unlike($res, qr/lists50/);
+
+# Test errors with too much memory
+my ($ret, $stdout, $stderr) = $node->psql("postgres",
+ "CREATE INDEX lists10000 ON tst USING ivfflat (v) WITH (lists = 10000);"
+);
+like($stderr, qr/memory required is/);
[parent: a37f5eea4a72]