Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb9c4ccf

Browse files
committed
Avoid catalog lookups in RelationAllowsEarlyPruning().
RelationAllowsEarlyPruning() performed a catalog scan, but is usedin two contexts where that was a bad idea:1. In heap_page_prune_opt(), which runs very frequently in some large scans. This caused major performance problems in a field report that was easy to reproduce.2. In TestForOldSnapshot(), which runs while we hold a buffer content lock. It's not clear if this was guaranteed to be free of buffer deadlock risk.The check was introduced in commit2cc41ac and defended against areal problem: 9.6's hash indexes have no page LSN and so we can'tallow early pruning (ie the snapshot-too-old feature). We can removethe check from all later releases though: hash indexes are now logged,and there is no way to create UNLOGGED indexes on regular loggedtables.If a future release allows such a combination, it might need to puta similar check in place, but it'll need some more thought.Back-patch to 10.Author: Thomas MunroReviewed-by: Tom Lane, who spotted the second problemDiscussion:https://postgr.es/m/CA%2BhUKGKT8oTkp5jw_U4p0S-7UG9zsvtw_M47Y285bER6a2gD%2Bg%40mail.gmail.comDiscussion:https://postgr.es/m/CAA4eK1%2BWy%2BN4eE5zPm765h68LrkWc3Biu_8rzzi%2BOYX4j%2BiHRw%40mail.gmail.com
1 parentf51006e commitb9c4ccf

File tree

3 files changed

+0
-44
lines changed

3 files changed

+0
-44
lines changed

‎src/backend/utils/cache/relcache.c

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6025,48 +6025,6 @@ RelationIdIsInInitFile(Oid relationId)
60256025
returnRelationSupportsSysCache(relationId);
60266026
}
60276027

6028-
/*
6029-
* Tells whether any index for the relation is unlogged.
6030-
*
6031-
* Note: There doesn't seem to be any way to have an unlogged index attached
6032-
* to a permanent table, but it seems best to keep this general so that it
6033-
* returns sensible results even when they seem obvious (like for an unlogged
6034-
* table) and to handle possible future unlogged indexes on permanent tables.
6035-
*/
6036-
bool
6037-
RelationHasUnloggedIndex(Relationrel)
6038-
{
6039-
List*indexoidlist;
6040-
ListCell*indexoidscan;
6041-
boolresult= false;
6042-
6043-
indexoidlist=RelationGetIndexList(rel);
6044-
6045-
foreach(indexoidscan,indexoidlist)
6046-
{
6047-
Oidindexoid=lfirst_oid(indexoidscan);
6048-
HeapTupletp;
6049-
Form_pg_classreltup;
6050-
6051-
tp=SearchSysCache1(RELOID,ObjectIdGetDatum(indexoid));
6052-
if (!HeapTupleIsValid(tp))
6053-
elog(ERROR,"cache lookup failed for relation %u",indexoid);
6054-
reltup= (Form_pg_class)GETSTRUCT(tp);
6055-
6056-
if (reltup->relpersistence==RELPERSISTENCE_UNLOGGED)
6057-
result= true;
6058-
6059-
ReleaseSysCache(tp);
6060-
6061-
if (result== true)
6062-
break;
6063-
}
6064-
6065-
list_free(indexoidlist);
6066-
6067-
returnresult;
6068-
}
6069-
60706028
/*
60716029
* Invalidate (remove) the init file during commit of a transaction that
60726030
* changed one or more of the relation cache entries that are kept in the

‎src/include/utils/rel.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,6 @@ typedef struct ViewOptions
602602
/* routines in utils/cache/relcache.c */
603603
externvoidRelationIncrementReferenceCount(Relationrel);
604604
externvoidRelationDecrementReferenceCount(Relationrel);
605-
externboolRelationHasUnloggedIndex(Relationrel);
606605
externList*RelationGetRepsetList(Relationrel);
607606

608607
#endif/* REL_H */

‎src/include/utils/snapmgr.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
RelationNeedsWAL(rel) \
4141
&& !IsCatalogRelation(rel) \
4242
&& !RelationIsAccessibleInLogicalDecoding(rel) \
43-
&& !RelationHasUnloggedIndex(rel) \
4443
)
4544

4645
#defineEarlyPruningEnabled(rel) (old_snapshot_threshold >= 0 && RelationAllowsEarlyPruning(rel))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp