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

Commit328c709

Browse files
committed
Optimize RelationFindReplTupleSeq() for CLOBBER_CACHE_ALWAYS.
Specifically, remember lookup_type_cache() results instead of retrievingthem once per comparison. Under CLOBBER_CACHE_ALWAYS, this reducedsrc/test/subscription/t/001_rep_changes.pl elapsed time by an order ofmagnitude, which reduced check-world elapsed time by 9%.Discussion:https://postgr.es/m/20200406085420.GC162712@rfd.leadboat.com
1 parent4216858 commit328c709

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

‎src/backend/executor/execReplication.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ RelationFindReplTupleByIndex(Relation rel, Oid idxoid,
225225
* Compare the tuples in the slots by checking if they have equal values.
226226
*/
227227
staticbool
228-
tuples_equal(TupleTableSlot*slot1,TupleTableSlot*slot2)
228+
tuples_equal(TupleTableSlot*slot1,TupleTableSlot*slot2,
229+
TypeCacheEntry**eq)
229230
{
230231
intattrnum;
231232

@@ -256,12 +257,18 @@ tuples_equal(TupleTableSlot *slot1, TupleTableSlot *slot2)
256257

257258
att=TupleDescAttr(slot1->tts_tupleDescriptor,attrnum);
258259

259-
typentry=lookup_type_cache(att->atttypid,TYPECACHE_EQ_OPR_FINFO);
260-
if (!OidIsValid(typentry->eq_opr_finfo.fn_oid))
261-
ereport(ERROR,
262-
(errcode(ERRCODE_UNDEFINED_FUNCTION),
263-
errmsg("could not identify an equality operator for type %s",
264-
format_type_be(att->atttypid))));
260+
typentry=eq[attrnum];
261+
if (typentry==NULL)
262+
{
263+
typentry=lookup_type_cache(att->atttypid,
264+
TYPECACHE_EQ_OPR_FINFO);
265+
if (!OidIsValid(typentry->eq_opr_finfo.fn_oid))
266+
ereport(ERROR,
267+
(errcode(ERRCODE_UNDEFINED_FUNCTION),
268+
errmsg("could not identify an equality operator for type %s",
269+
format_type_be(att->atttypid))));
270+
eq[attrnum]=typentry;
271+
}
265272

266273
if (!DatumGetBool(FunctionCall2Coll(&typentry->eq_opr_finfo,
267274
att->attcollation,
@@ -290,12 +297,15 @@ RelationFindReplTupleSeq(Relation rel, LockTupleMode lockmode,
290297
TupleTableSlot*scanslot;
291298
TableScanDescscan;
292299
SnapshotDatasnap;
300+
TypeCacheEntry**eq;
293301
TransactionIdxwait;
294302
boolfound;
295303
TupleDescdescPG_USED_FOR_ASSERTS_ONLY=RelationGetDescr(rel);
296304

297305
Assert(equalTupleDescs(desc,outslot->tts_tupleDescriptor));
298306

307+
eq=palloc0(sizeof(*eq)*outslot->tts_tupleDescriptor->natts);
308+
299309
/* Start a heap scan. */
300310
InitDirtySnapshot(snap);
301311
scan=table_beginscan(rel,&snap,0,NULL);
@@ -309,7 +319,7 @@ RelationFindReplTupleSeq(Relation rel, LockTupleMode lockmode,
309319
/* Try to find the tuple */
310320
while (table_scan_getnextslot(scan,ForwardScanDirection,scanslot))
311321
{
312-
if (!tuples_equal(scanslot,searchslot))
322+
if (!tuples_equal(scanslot,searchslot,eq))
313323
continue;
314324

315325
found= true;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp