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

Commit8cc6016

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 parente96f524 commit8cc6016

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
@@ -5941,48 +5941,6 @@ RelationIdIsInInitFile(Oid relationId)
59415941
returnRelationSupportsSysCache(relationId);
59425942
}
59435943

5944-
/*
5945-
* Tells whether any index for the relation is unlogged.
5946-
*
5947-
* Note: There doesn't seem to be any way to have an unlogged index attached
5948-
* to a permanent table, but it seems best to keep this general so that it
5949-
* returns sensible results even when they seem obvious (like for an unlogged
5950-
* table) and to handle possible future unlogged indexes on permanent tables.
5951-
*/
5952-
bool
5953-
RelationHasUnloggedIndex(Relationrel)
5954-
{
5955-
List*indexoidlist;
5956-
ListCell*indexoidscan;
5957-
boolresult= false;
5958-
5959-
indexoidlist=RelationGetIndexList(rel);
5960-
5961-
foreach(indexoidscan,indexoidlist)
5962-
{
5963-
Oidindexoid=lfirst_oid(indexoidscan);
5964-
HeapTupletp;
5965-
Form_pg_classreltup;
5966-
5967-
tp=SearchSysCache1(RELOID,ObjectIdGetDatum(indexoid));
5968-
if (!HeapTupleIsValid(tp))
5969-
elog(ERROR,"cache lookup failed for relation %u",indexoid);
5970-
reltup= (Form_pg_class)GETSTRUCT(tp);
5971-
5972-
if (reltup->relpersistence==RELPERSISTENCE_UNLOGGED)
5973-
result= true;
5974-
5975-
ReleaseSysCache(tp);
5976-
5977-
if (result== true)
5978-
break;
5979-
}
5980-
5981-
list_free(indexoidlist);
5982-
5983-
returnresult;
5984-
}
5985-
59865944
/*
59875945
* Invalidate (remove) the init file during commit of a transaction that
59885946
* 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
@@ -606,7 +606,6 @@ typedef struct ViewOptions
606606
/* routines in utils/cache/relcache.c */
607607
externvoidRelationIncrementReferenceCount(Relationrel);
608608
externvoidRelationDecrementReferenceCount(Relationrel);
609-
externboolRelationHasUnloggedIndex(Relationrel);
610609
externList*RelationGetRepsetList(Relationrel);
611610

612611
#endif/* REL_H */

‎src/include/utils/snapmgr.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
RelationNeedsWAL(rel) \
4242
&& !IsCatalogRelation(rel) \
4343
&& !RelationIsAccessibleInLogicalDecoding(rel) \
44-
&& !RelationHasUnloggedIndex(rel) \
4544
)
4645

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp