mirror of
https://github.com/postgres/postgres.git
synced 2026-04-14 05:27:20 -04:00
Remove table_scan_analyze_next_tuple unneeded parameter OldestXmin
heapam_scan_analyze_next_tuple() doesn't distinguish between dead and recently dead tuples when counting them, so it doesn't need OldestXmin. GetOldestNonRemovableTransactionId() isn't free, so removing it is a win. Looking at other table AMs implementing table_scan_analyze_next_tuple(), we couldn't find one using OldestXmin either, so remove it from the callback. Author: Melanie Plageman <melanieplageman@gmail.com> Suggested-by: Kirill Reshke <reshkekirill@gmail.com> Reviewed-by: Kirill Reshke <reshkekirill@gmail.com> Reviewed-by: Andres Freund <andres@anarazel.de> Reviewed-by: Chao Li <li.evan.chao@gmail.com> Discussion: https://postgr.es/m/CALdSSPjvhGXihT_9f-GJabYU%3D_PjrFDUxYaURuTbfLyQM6TErg%40mail.gmail.com
This commit is contained in:
parent
3efe58febc
commit
284925508a
3 changed files with 8 additions and 11 deletions
|
|
@ -1040,7 +1040,7 @@ heapam_scan_analyze_next_block(TableScanDesc scan, ReadStream *stream)
|
|||
}
|
||||
|
||||
static bool
|
||||
heapam_scan_analyze_next_tuple(TableScanDesc scan, TransactionId OldestXmin,
|
||||
heapam_scan_analyze_next_tuple(TableScanDesc scan,
|
||||
double *liverows, double *deadrows,
|
||||
TupleTableSlot *slot)
|
||||
{
|
||||
|
|
@ -1061,6 +1061,7 @@ heapam_scan_analyze_next_tuple(TableScanDesc scan, TransactionId OldestXmin,
|
|||
ItemId itemid;
|
||||
HeapTuple targtuple = &hslot->base.tupdata;
|
||||
bool sample_it = false;
|
||||
TransactionId dead_after;
|
||||
|
||||
itemid = PageGetItemId(targpage, hscan->rs_cindex);
|
||||
|
||||
|
|
@ -1083,8 +1084,9 @@ heapam_scan_analyze_next_tuple(TableScanDesc scan, TransactionId OldestXmin,
|
|||
targtuple->t_data = (HeapTupleHeader) PageGetItem(targpage, itemid);
|
||||
targtuple->t_len = ItemIdGetLength(itemid);
|
||||
|
||||
switch (HeapTupleSatisfiesVacuum(targtuple, OldestXmin,
|
||||
hscan->rs_cbuf))
|
||||
switch (HeapTupleSatisfiesVacuumHorizon(targtuple,
|
||||
hscan->rs_cbuf,
|
||||
&dead_after))
|
||||
{
|
||||
case HEAPTUPLE_LIVE:
|
||||
sample_it = true;
|
||||
|
|
|
|||
|
|
@ -1213,7 +1213,6 @@ acquire_sample_rows(Relation onerel, int elevel,
|
|||
double rowstoskip = -1; /* -1 means not set yet */
|
||||
uint32 randseed; /* Seed for block sampler(s) */
|
||||
BlockNumber totalblocks;
|
||||
TransactionId OldestXmin;
|
||||
BlockSamplerData bs;
|
||||
ReservoirStateData rstate;
|
||||
TupleTableSlot *slot;
|
||||
|
|
@ -1226,9 +1225,6 @@ acquire_sample_rows(Relation onerel, int elevel,
|
|||
|
||||
totalblocks = RelationGetNumberOfBlocks(onerel);
|
||||
|
||||
/* Need a cutoff xmin for HeapTupleSatisfiesVacuum */
|
||||
OldestXmin = GetOldestNonRemovableTransactionId(onerel);
|
||||
|
||||
/* Prepare for sampling block numbers */
|
||||
randseed = pg_prng_uint32(&pg_global_prng_state);
|
||||
nblocks = BlockSampler_Init(&bs, totalblocks, targrows, randseed);
|
||||
|
|
@ -1261,7 +1257,7 @@ acquire_sample_rows(Relation onerel, int elevel,
|
|||
{
|
||||
vacuum_delay_point(true);
|
||||
|
||||
while (table_scan_analyze_next_tuple(scan, OldestXmin, &liverows, &deadrows, slot))
|
||||
while (table_scan_analyze_next_tuple(scan, &liverows, &deadrows, slot))
|
||||
{
|
||||
/*
|
||||
* The first targrows sample rows are simply copied into the
|
||||
|
|
|
|||
|
|
@ -683,7 +683,6 @@ typedef struct TableAmRoutine
|
|||
* callback).
|
||||
*/
|
||||
bool (*scan_analyze_next_tuple) (TableScanDesc scan,
|
||||
TransactionId OldestXmin,
|
||||
double *liverows,
|
||||
double *deadrows,
|
||||
TupleTableSlot *slot);
|
||||
|
|
@ -1726,11 +1725,11 @@ table_scan_analyze_next_block(TableScanDesc scan, ReadStream *stream)
|
|||
* tuples.
|
||||
*/
|
||||
static inline bool
|
||||
table_scan_analyze_next_tuple(TableScanDesc scan, TransactionId OldestXmin,
|
||||
table_scan_analyze_next_tuple(TableScanDesc scan,
|
||||
double *liverows, double *deadrows,
|
||||
TupleTableSlot *slot)
|
||||
{
|
||||
return scan->rs_rd->rd_tableam->scan_analyze_next_tuple(scan, OldestXmin,
|
||||
return scan->rs_rd->rd_tableam->scan_analyze_next_tuple(scan,
|
||||
liverows, deadrows,
|
||||
slot);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue