Skip to content

remove additional and useless loop for each relation file when do ptrack_get_pagemapset query #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions ptrack.c
Original file line number Diff line number Diff line change
@@ -368,6 +368,14 @@ ptrack_filelist_getnext(PtScanCtx * ctx)
return ptrack_filelist_getnext(ctx);
}

if (fst.st_size == 0)
{
elog(WARNING, "ptrack: skip empty file %s", fullpath);

/* But try the next one */
return ptrack_filelist_getnext(ctx);
}

if (pfl->segno > 0)
{
ctx->relsize = pfl->segno * RELSEG_SIZE + fst.st_size / BLCKSZ;
@@ -494,7 +502,7 @@ ptrack_get_pagemapset(PG_FUNCTION_ARGS)
XLogRecPtr update_lsn2;

/* Stop traversal if there are no more segments */
if (ctx->bid.blocknum > ctx->relsize)
if (ctx->bid.blocknum >= ctx->relsize)
{
/* We completed a segment and there is a bitmap to return */
if (pagemap.bitmap != NULL)
@@ -526,12 +534,9 @@ ptrack_get_pagemapset(PG_FUNCTION_ARGS)
if (htup)
SRF_RETURN_NEXT(funcctx, HeapTupleGetDatum(htup));
}
else
{
/* We have just processed unchanged file, let's pick next */
if (ptrack_filelist_getnext(ctx) < 0)
SRF_RETURN_DONE(funcctx);
}

if (ptrack_filelist_getnext(ctx) < 0)
SRF_RETURN_DONE(funcctx);
}

hash = BID_HASH_FUNC(ctx->bid);