mirror of
https://github.com/postgres/postgres.git
synced 2025-05-12 16:21:30 +03:00
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
This commit is contained in:
parent
4f5d461e04
commit
a4f23f9b3c
@ -217,17 +217,17 @@ my $rel = $node->safe_psql('postgres',
|
|||||||
my $relpath = "$pgdata/$rel";
|
my $relpath = "$pgdata/$rel";
|
||||||
|
|
||||||
# Insert data and freeze public.test
|
# Insert data and freeze public.test
|
||||||
use constant ROWCOUNT => 17;
|
my $ROWCOUNT = 17;
|
||||||
$node->safe_psql(
|
$node->safe_psql(
|
||||||
'postgres', qq(
|
'postgres', qq(
|
||||||
INSERT INTO public.test (a, b, c)
|
INSERT INTO public.test (a, b, c)
|
||||||
VALUES (
|
SELECT
|
||||||
x'DEADF9F9DEADF9F9'::bigint,
|
x'DEADF9F9DEADF9F9'::bigint,
|
||||||
'abcdefg',
|
'abcdefg',
|
||||||
repeat('w', 10000)
|
repeat('w', 10000)
|
||||||
);
|
FROM generate_series(1, $ROWCOUNT);
|
||||||
VACUUM FREEZE public.test
|
VACUUM FREEZE public.test;)
|
||||||
)) for (1 .. ROWCOUNT);
|
);
|
||||||
|
|
||||||
my $relfrozenxid = $node->safe_psql('postgres',
|
my $relfrozenxid = $node->safe_psql('postgres',
|
||||||
q(select relfrozenxid from pg_class where relname = 'test'));
|
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.
|
# Find where each of the tuples is located on the page.
|
||||||
my @lp_off;
|
my @lp_off = split '\n', $node->safe_psql(
|
||||||
for my $tup (0 .. ROWCOUNT - 1)
|
|
||||||
{
|
|
||||||
push(
|
|
||||||
@lp_off,
|
|
||||||
$node->safe_psql(
|
|
||||||
'postgres', qq(
|
'postgres', qq(
|
||||||
select lp_off from heap_page_items(get_raw_page('test', 'main', 0))
|
select lp_off from heap_page_items(get_raw_page('test', 'main', 0))
|
||||||
offset $tup limit 1)));
|
where lp <= $ROWCOUNT
|
||||||
}
|
)
|
||||||
|
);
|
||||||
|
is(scalar @lp_off, $ROWCOUNT, "acquired row offsets");
|
||||||
|
|
||||||
# Sanity check that our 'test' table on disk layout matches expectations. If
|
# 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
|
# 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;
|
binmode $file;
|
||||||
|
|
||||||
my $ENDIANNESS;
|
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 $offnum = $tupidx + 1; # offnum is 1-based, not zero-based
|
||||||
my $offset = $lp_off[$tupidx];
|
my $offset = $lp_off[$tupidx];
|
||||||
@ -345,7 +342,7 @@ open($file, '+<', $relpath)
|
|||||||
or BAIL_OUT("open failed: $!");
|
or BAIL_OUT("open failed: $!");
|
||||||
binmode $file;
|
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 $offnum = $tupidx + 1; # offnum is 1-based, not zero-based
|
||||||
my $offset = $lp_off[$tupidx];
|
my $offset = $lp_off[$tupidx];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user