Improved test for inserts

This commit is contained in:
Andrew Kane
2022-11-02 14:29:41 -07:00
parent fb819eb8b2
commit 386a3b5dd5

View File

@@ -2,12 +2,12 @@ use strict;
use warnings;
use PostgresNode;
use TestLib;
use Test::More tests => 3;
# TODO fix randomness
use Test::More tests => 5;
my $dim = 768;
my $array_sql = join(",", ('random()') x $dim);
# Initialize node
my $node = get_new_node('node');
$node->init;
@@ -17,7 +17,7 @@ $node->start;
$node->safe_psql("postgres", "CREATE EXTENSION vector;");
$node->safe_psql("postgres", "CREATE TABLE tst (v vector($dim));");
$node->safe_psql("postgres",
"INSERT INTO tst SELECT (SELECT array_agg(random()) FROM generate_series(1, $dim)) FROM generate_series(1, 10000) i;"
"INSERT INTO tst SELECT ARRAY[$array_sql] FROM generate_series(1, 10000) i;"
);
$node->safe_psql("postgres", "CREATE INDEX ON tst USING ivfflat (v);");
@@ -28,6 +28,18 @@ $node->pgbench(
[qr{^$}],
"concurrent INSERTs",
{
"007_concurrent" => "INSERT INTO tst SELECT (SELECT array_agg(random()) FROM generate_series(1, $dim)) FROM generate_series(1, 10) i;"
"007_inserts" => "INSERT INTO tst SELECT ARRAY[$array_sql] FROM generate_series(1, 10) i;"
}
);
my $expected = 10000 + 5 * 100 * 10;
my $count = $node->safe_psql("postgres", "SELECT COUNT(*) FROM tst;");
is($count, $expected);
$count = $node->safe_psql("postgres", qq(
SET enable_seqscan = off;
SET ivfflat.probes = 100;
SELECT COUNT(*) FROM (SELECT v FROM tst ORDER BY v <-> (SELECT v FROM tst LIMIT 1)) t;
));
is($count, $expected);