mirror of
https://github.com/postgres/postgres.git
synced 2025-07-09 22:41:56 +03:00
tableam: Avoid relying on relation size to determine validity of tids.
Instead add a tableam callback to do so. To avoid adding per validation overhead, pass a scan to tuple_tid_valid. In heap's case we'd otherwise incurred a RelationGetNumberOfBlocks() call for each tid - which'd have added noticable overhead to nodeTidscan.c. Author: Andres Freund Reviewed-By: Ashwin Agrawal Discussion: https://postgr.es/m/20190515185447.gno2jtqxyktylyvs@alap3.anarazel.de
This commit is contained in:
@ -204,6 +204,15 @@ heapam_fetch_row_version(Relation relation,
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool
|
||||
heapam_tuple_tid_valid(TableScanDesc scan, ItemPointer tid)
|
||||
{
|
||||
HeapScanDesc hscan = (HeapScanDesc) scan;
|
||||
|
||||
return ItemPointerIsValid(tid) &&
|
||||
ItemPointerGetBlockNumber(tid) < hscan->rs_nblocks;
|
||||
}
|
||||
|
||||
static bool
|
||||
heapam_tuple_satisfies_snapshot(Relation rel, TupleTableSlot *slot,
|
||||
Snapshot snapshot)
|
||||
@ -2568,6 +2577,7 @@ static const TableAmRoutine heapam_methods = {
|
||||
|
||||
.tuple_fetch_row_version = heapam_fetch_row_version,
|
||||
.tuple_get_latest_tid = heap_get_latest_tid,
|
||||
.tuple_tid_valid = heapam_tuple_tid_valid,
|
||||
.tuple_satisfies_snapshot = heapam_tuple_satisfies_snapshot,
|
||||
.compute_xid_horizon_for_tuples = heap_compute_xid_horizon_for_tuples,
|
||||
|
||||
|
Reference in New Issue
Block a user