mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +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:
@ -358,6 +358,7 @@ currtid_byreloid(PG_FUNCTION_ARGS)
|
||||
Relation rel;
|
||||
AclResult aclresult;
|
||||
Snapshot snapshot;
|
||||
TableScanDesc scan;
|
||||
|
||||
result = (ItemPointer) palloc(sizeof(ItemPointerData));
|
||||
if (!reloid)
|
||||
@ -380,7 +381,9 @@ currtid_byreloid(PG_FUNCTION_ARGS)
|
||||
ItemPointerCopy(tid, result);
|
||||
|
||||
snapshot = RegisterSnapshot(GetLatestSnapshot());
|
||||
table_get_latest_tid(rel, snapshot, result);
|
||||
scan = table_beginscan(rel, snapshot, 0, NULL);
|
||||
table_get_latest_tid(scan, result);
|
||||
table_endscan(scan);
|
||||
UnregisterSnapshot(snapshot);
|
||||
|
||||
table_close(rel, AccessShareLock);
|
||||
@ -398,6 +401,7 @@ currtid_byrelname(PG_FUNCTION_ARGS)
|
||||
Relation rel;
|
||||
AclResult aclresult;
|
||||
Snapshot snapshot;
|
||||
TableScanDesc scan;
|
||||
|
||||
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
|
||||
rel = table_openrv(relrv, AccessShareLock);
|
||||
@ -415,7 +419,9 @@ currtid_byrelname(PG_FUNCTION_ARGS)
|
||||
ItemPointerCopy(tid, result);
|
||||
|
||||
snapshot = RegisterSnapshot(GetLatestSnapshot());
|
||||
table_get_latest_tid(rel, snapshot, result);
|
||||
scan = table_beginscan(rel, snapshot, 0, NULL);
|
||||
table_get_latest_tid(scan, result);
|
||||
table_endscan(scan);
|
||||
UnregisterSnapshot(snapshot);
|
||||
|
||||
table_close(rel, AccessShareLock);
|
||||
|
Reference in New Issue
Block a user