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

Commit65158f4

Browse files
committed
Remove small inefficiency in ExecARDeleteTriggers/ExecARUpdateTriggers.
Whilst poking at nodeModifyTable.c, I chanced to notice that whileits calls to ExecBR*Triggers and ExecIR*Triggers are protected bytests to see if there are any relevant triggers to fire, its callsto ExecAR*Triggers are not; the latter functions do the equivalenttests themselves. This seems possibly reasonable given the morecomplex conditions involved, but what's less reasonable is thatthe ExecAR* functions aren't careful to do no work when there isno work to be done. ExecARInsertTriggers gets this right, but theother two will both force creation of a slot that the query mayhave no use for. ExecARUpdateTriggers additionally performed ausually-useless ExecClearTuple() on that slot. This is probablyall pretty microscopic in real workloads, but a cycle shaved is acycle earned.
1 parent9ee7d53 commit65158f4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

‎src/backend/commands/trigger.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2546,11 +2546,12 @@ ExecARDeleteTriggers(EState *estate, ResultRelInfo *relinfo,
25462546
TransitionCaptureState*transition_capture)
25472547
{
25482548
TriggerDesc*trigdesc=relinfo->ri_TrigDesc;
2549-
TupleTableSlot*slot=ExecGetTriggerOldSlot(estate,relinfo);
25502549

25512550
if ((trigdesc&&trigdesc->trig_delete_after_row)||
25522551
(transition_capture&&transition_capture->tcs_delete_old_table))
25532552
{
2553+
TupleTableSlot*slot=ExecGetTriggerOldSlot(estate,relinfo);
2554+
25542555
Assert(HeapTupleIsValid(fdw_trigtuple) ^ItemPointerIsValid(tupleid));
25552556
if (fdw_trigtuple==NULL)
25562557
GetTupleForTrigger(estate,
@@ -2829,9 +2830,6 @@ ExecARUpdateTriggers(EState *estate, ResultRelInfo *relinfo,
28292830
TransitionCaptureState*transition_capture)
28302831
{
28312832
TriggerDesc*trigdesc=relinfo->ri_TrigDesc;
2832-
TupleTableSlot*oldslot=ExecGetTriggerOldSlot(estate,relinfo);
2833-
2834-
ExecClearTuple(oldslot);
28352833

28362834
if ((trigdesc&&trigdesc->trig_update_after_row)||
28372835
(transition_capture&&
@@ -2844,6 +2842,8 @@ ExecARUpdateTriggers(EState *estate, ResultRelInfo *relinfo,
28442842
* separately for DELETE and INSERT to capture transition table rows.
28452843
* In such case, either old tuple or new tuple can be NULL.
28462844
*/
2845+
TupleTableSlot*oldslot=ExecGetTriggerOldSlot(estate,relinfo);
2846+
28472847
if (fdw_trigtuple==NULL&&ItemPointerIsValid(tupleid))
28482848
GetTupleForTrigger(estate,
28492849
NULL,
@@ -2854,6 +2854,8 @@ ExecARUpdateTriggers(EState *estate, ResultRelInfo *relinfo,
28542854
NULL);
28552855
elseif (fdw_trigtuple!=NULL)
28562856
ExecForceStoreHeapTuple(fdw_trigtuple,oldslot, false);
2857+
else
2858+
ExecClearTuple(oldslot);
28572859

28582860
AfterTriggerSaveEvent(estate,relinfo,TRIGGER_EVENT_UPDATE,
28592861
true,oldslot,newslot,recheckIndexes,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp