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

Commit7921927

Browse files
committed
Reverse the search order in afterTriggerAddEvent().
When scanning existing AfterTriggerSharedData records in searchof a match to the event being queued, we were examining therecords from oldest to newest. But it makes more sense to dothe opposite. The newest record is likely to be from the currentquery, while the oldest is likely to be from some previous commandin the same transaction, which will likely have different details.There aren't expected to be very many active AfterTriggerSharedDatarecords at once, so that this change is unlikely to make anyspectacular difference. Still, having added a nontrivially-expensivebms_equal call to this loop yesterday, I feel a need to shave cycleswhere possible.Discussion:https://postgr.es/m/4166712.1737583961@sss.pgh.pa.us
1 parentb663b94 commit7921927

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

‎src/backend/commands/trigger.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4104,11 +4104,12 @@ afterTriggerAddEvent(AfterTriggerEventList *events,
41044104

41054105
/*
41064106
* Try to locate a matching shared-data record already in the chunk. If
4107-
* none, make a new one.
4107+
* none, make a new one. The search begins with the most recently added
4108+
* record, since newer ones are most likely to match.
41084109
*/
4109-
for (newshared= ((AfterTriggerShared)chunk->endptr)-1;
4110-
(char*)newshared>=chunk->endfree;
4111-
newshared--)
4110+
for (newshared= (AfterTriggerShared)chunk->endfree;
4111+
(char*)newshared<chunk->endptr;
4112+
newshared++)
41124113
{
41134114
/* compare fields roughly by probability of them being different */
41144115
if (newshared->ats_tgoid==evtshared->ats_tgoid&&
@@ -4120,8 +4121,9 @@ afterTriggerAddEvent(AfterTriggerEventList *events,
41204121
evtshared->ats_modifiedcols))
41214122
break;
41224123
}
4123-
if ((char*)newshared<chunk->endfree)
4124+
if ((char*)newshared>=chunk->endptr)
41244125
{
4126+
newshared= ((AfterTriggerShared)chunk->endfree)-1;
41254127
*newshared=*evtshared;
41264128
/* now we must make a suitably-long-lived copy of the bitmap */
41274129
newshared->ats_modifiedcols=afterTriggerCopyBitmap(evtshared->ats_modifiedcols);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp