aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2023-03-11 15:41:47 -0800
committerAndres Freund <andres@anarazel.de>2023-03-11 15:41:47 -0800
commita4f23f9b3cddb86137a3b1683dcbe49d8b41ea7b (patch)
treef6c0a659a1179c5d85a0f5d965c03dd44c6d918f /src
parent4f5d461e048b9c56fe2fa8c7faf7010eed05ba82 (diff)
downloadpostgresql-a4f23f9b3cddb86137a3b1683dcbe49d8b41ea7b.tar.gz
postgresql-a4f23f9b3cddb86137a3b1683dcbe49d8b41ea7b.zip
pg_amcheck: Minor test speedups
Freezing the relation N times and fetching the tuples one-by-one isn't that cheap. On my machine this reduces test times by a bit less than one second, on windows CI it's a few seconds. Reviewed-by: Mark Dilger <mark.dilger@enterprisedb.com> Discussion: https://postgr.es/m/20230309001558.b7shzvio645ebdta@awork3.anarazel.de
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_amcheck/t/004_verify_heapam.pl33
1 files changed, 15 insertions, 18 deletions
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index 9984d0d9f87..e5ae7e6aada 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -217,17 +217,17 @@ my $rel = $node->safe_psql('postgres',
my $relpath = "$pgdata/$rel";
# Insert data and freeze public.test
-use constant ROWCOUNT => 17;
+my $ROWCOUNT = 17;
$node->safe_psql(
'postgres', qq(
INSERT INTO public.test (a, b, c)
- VALUES (
+ SELECT
x'DEADF9F9DEADF9F9'::bigint,
'abcdefg',
repeat('w', 10000)
- );
- VACUUM FREEZE public.test
- )) for (1 .. ROWCOUNT);
+ FROM generate_series(1, $ROWCOUNT);
+ VACUUM FREEZE public.test;)
+);
my $relfrozenxid = $node->safe_psql('postgres',
q(select relfrozenxid from pg_class where relname = 'test'));
@@ -246,16 +246,13 @@ if ($datfrozenxid <= 3 || $datfrozenxid >= $relfrozenxid)
}
# Find where each of the tuples is located on the page.
-my @lp_off;
-for my $tup (0 .. ROWCOUNT - 1)
-{
- push(
- @lp_off,
- $node->safe_psql(
- 'postgres', qq(
-select lp_off from heap_page_items(get_raw_page('test', 'main', 0))
- offset $tup limit 1)));
-}
+my @lp_off = split '\n', $node->safe_psql(
+ 'postgres', qq(
+ select lp_off from heap_page_items(get_raw_page('test', 'main', 0))
+ where lp <= $ROWCOUNT
+ )
+);
+is(scalar @lp_off, $ROWCOUNT, "acquired row offsets");
# Sanity check that our 'test' table on disk layout matches expectations. If
# this is not so, we will have to skip the test until somebody updates the test
@@ -267,7 +264,7 @@ open($file, '+<', $relpath)
binmode $file;
my $ENDIANNESS;
-for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
+for (my $tupidx = 0; $tupidx < $ROWCOUNT; $tupidx++)
{
my $offnum = $tupidx + 1; # offnum is 1-based, not zero-based
my $offset = $lp_off[$tupidx];
@@ -345,7 +342,7 @@ open($file, '+<', $relpath)
or BAIL_OUT("open failed: $!");
binmode $file;
-for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
+for (my $tupidx = 0; $tupidx < $ROWCOUNT; $tupidx++)
{
my $offnum = $tupidx + 1; # offnum is 1-based, not zero-based
my $offset = $lp_off[$tupidx];
@@ -522,7 +519,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin ${xmin} equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin ${xmin} equals or exceeds next valid transaction ID 0:\d+/;
}
write_tuple($file, $offset, $tup);
}