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

Commit3d9e8db

Browse files
committed
Revert "Fix an O(N^2) problem in foreign key references".
Commit5ddc728 does not actually workbecause it will happily blow away ri_constraint_cache entries that arein active use in outer call levels. In any case, it's a very ugly,brute-force solution to the problem of limiting the cache size.Revert until it can be redesigned.
1 parent6820094 commit3d9e8db

File tree

1 file changed

+3
-35
lines changed

1 file changed

+3
-35
lines changed

‎src/backend/utils/adt/ri_triggers.c

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ typedef struct RI_CompareHashEntry
183183
* ----------
184184
*/
185185
staticHTAB*ri_constraint_cache=NULL;
186-
staticlongri_constraint_cache_seq_count=0;
187186
staticHTAB*ri_query_cache=NULL;
188187
staticHTAB*ri_compare_cache=NULL;
189188

@@ -216,7 +215,6 @@ static bool ri_KeysEqual(Relation rel, HeapTuple oldtup, HeapTuple newtup,
216215
staticboolri_AttributesEqual(Oideq_opr,Oidtypeid,
217216
Datumoldvalue,Datumnewvalue);
218217

219-
staticvoidri_InitConstraintCache(void);
220218
staticvoidri_InitHashTables(void);
221219
staticvoidInvalidateConstraintCacheCallBack(Datumarg,intcacheid,uint32hashvalue);
222220
staticSPIPlanPtrri_FetchPreparedPlan(RI_QueryKey*key);
@@ -2947,20 +2945,6 @@ InvalidateConstraintCacheCallBack(Datum arg, int cacheid, uint32 hashvalue)
29472945

29482946
Assert(ri_constraint_cache!=NULL);
29492947

2950-
/*
2951-
* Prevent an O(N^2) problem when creating large amounts of foreign
2952-
* key constraints with ALTER TABLE, like it happens at the end of
2953-
* a pg_dump with hundred-thousands of tables having references.
2954-
*/
2955-
ri_constraint_cache_seq_count+=hash_get_num_entries(ri_constraint_cache);
2956-
if (ri_constraint_cache_seq_count>1000000)
2957-
{
2958-
hash_destroy(ri_constraint_cache);
2959-
ri_InitConstraintCache();
2960-
ri_constraint_cache_seq_count=0;
2961-
return;
2962-
}
2963-
29642948
hash_seq_init(&status,ri_constraint_cache);
29652949
while ((hentry= (RI_ConstraintInfo*)hash_seq_search(&status))!=NULL)
29662950
{
@@ -3380,15 +3364,13 @@ ri_NullCheck(HeapTuple tup,
33803364

33813365

33823366
/* ----------
3383-
* ri_InitConstraintCache
3384-
*
3385-
* Initialize ri_constraint_cache when new or being rebuilt.
3367+
* ri_InitHashTables -
33863368
*
3387-
* This needs to be done from two places, so split it out to prevent drift.
3369+
*Initialize our internal hash tables.
33883370
* ----------
33893371
*/
33903372
staticvoid
3391-
ri_InitConstraintCache(void)
3373+
ri_InitHashTables(void)
33923374
{
33933375
HASHCTLctl;
33943376

@@ -3398,20 +3380,6 @@ ri_InitConstraintCache(void)
33983380
ri_constraint_cache=hash_create("RI constraint cache",
33993381
RI_INIT_CONSTRAINTHASHSIZE,
34003382
&ctl,HASH_ELEM |HASH_BLOBS);
3401-
}
3402-
3403-
/* ----------
3404-
* ri_InitHashTables -
3405-
*
3406-
*Initialize our internal hash tables.
3407-
* ----------
3408-
*/
3409-
staticvoid
3410-
ri_InitHashTables(void)
3411-
{
3412-
HASHCTLctl;
3413-
3414-
ri_InitConstraintCache();
34153383

34163384
/* Arrange to flush cache on pg_constraint changes */
34173385
CacheRegisterSyscacheCallback(CONSTROID,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp