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

Commiteeb68c1

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 parent19bfa15 commiteeb68c1

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
@@ -6068,48 +6068,6 @@ RelationIdIsInInitFile(Oid relationId)
60686068
returnRelationSupportsSysCache(relationId);
60696069
}
60706070

6071-
/*
6072-
* Tells whether any index for the relation is unlogged.
6073-
*
6074-
* Note: There doesn't seem to be any way to have an unlogged index attached
6075-
* to a permanent table, but it seems best to keep this general so that it
6076-
* returns sensible results even when they seem obvious (like for an unlogged
6077-
* table) and to handle possible future unlogged indexes on permanent tables.
6078-
*/
6079-
bool
6080-
RelationHasUnloggedIndex(Relationrel)
6081-
{
6082-
List*indexoidlist;
6083-
ListCell*indexoidscan;
6084-
boolresult= false;
6085-
6086-
indexoidlist=RelationGetIndexList(rel);
6087-
6088-
foreach(indexoidscan,indexoidlist)
6089-
{
6090-
Oidindexoid=lfirst_oid(indexoidscan);
6091-
HeapTupletp;
6092-
Form_pg_classreltup;
6093-
6094-
tp=SearchSysCache1(RELOID,ObjectIdGetDatum(indexoid));
6095-
if (!HeapTupleIsValid(tp))
6096-
elog(ERROR,"cache lookup failed for relation %u",indexoid);
6097-
reltup= (Form_pg_class)GETSTRUCT(tp);
6098-
6099-
if (reltup->relpersistence==RELPERSISTENCE_UNLOGGED)
6100-
result= true;
6101-
6102-
ReleaseSysCache(tp);
6103-
6104-
if (result== true)
6105-
break;
6106-
}
6107-
6108-
list_free(indexoidlist);
6109-
6110-
returnresult;
6111-
}
6112-
61136071
/*
61146072
* Invalidate (remove) the init file during commit of a transaction that
61156073
* 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
@@ -638,7 +638,6 @@ get_partition_col_typmod(PartitionKey key, int col)
638638
/* routines in utils/cache/relcache.c */
639639
externvoidRelationIncrementReferenceCount(Relationrel);
640640
externvoidRelationDecrementReferenceCount(Relationrel);
641-
externboolRelationHasUnloggedIndex(Relationrel);
642641
externList*RelationGetRepsetList(Relationrel);
643642

644643
#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