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

Commitc1e0e7e

Browse files
committed
Speed up dropping tables with many partitions.
We need to lock the parent, but we don't need a relcache entryfor it.Gao Zeng Qi, reviewed by Amit LangoteDiscussion:http://postgr.es/m/CAFmBtr0ukqJjRJEhPWL5wt4rNMrJUUxggVAGXPR3SyYh3E+HDQ@mail.gmail.com
1 parent504c220 commitc1e0e7e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

‎src/backend/catalog/heap.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
#include"parser/parse_collate.h"
6969
#include"parser/parse_expr.h"
7070
#include"parser/parse_relation.h"
71+
#include"storage/lmgr.h"
7172
#include"storage/predicate.h"
7273
#include"storage/smgr.h"
7374
#include"utils/acl.h"
@@ -1760,8 +1761,7 @@ heap_drop_with_catalog(Oid relid)
17601761
{
17611762
Relationrel;
17621763
HeapTupletuple;
1763-
OidparentOid;
1764-
Relationparent=NULL;
1764+
OidparentOid=InvalidOid;
17651765

17661766
/*
17671767
* To drop a partition safely, we must grab exclusive lock on its parent,
@@ -1776,7 +1776,7 @@ heap_drop_with_catalog(Oid relid)
17761776
if (((Form_pg_class)GETSTRUCT(tuple))->relispartition)
17771777
{
17781778
parentOid=get_partition_parent(relid);
1779-
parent=heap_open(parentOid,AccessExclusiveLock);
1779+
LockRelationOid(parentOid,AccessExclusiveLock);
17801780
}
17811781

17821782
ReleaseSysCache(tuple);
@@ -1885,14 +1885,14 @@ heap_drop_with_catalog(Oid relid)
18851885
*/
18861886
DeleteRelationTuple(relid);
18871887

1888-
if (parent)
1888+
if (OidIsValid(parentOid))
18891889
{
18901890
/*
18911891
* Invalidate the parent's relcache so that the partition is no longer
18921892
* included in its partition descriptor.
18931893
*/
1894-
CacheInvalidateRelcache(parent);
1895-
heap_close(parent,NoLock);/* keep the lock */
1894+
CacheInvalidateRelcacheByRelid(parentOid);
1895+
/* keep the lock */
18961896
}
18971897
}
18981898

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp