Reverse the search order in afterTriggerAddEvent().
authorTom Lane
Thu, 23 Jan 2025 16:08:05 +0000 (11:08 -0500)
committerTom Lane
Thu, 23 Jan 2025 16:08:05 +0000 (11:08 -0500)
commit7921927bbb9d4a80ced9283b27c26eedb638f555
tree243a769c3ab4dd418f29839e3b10728544e66f5a
parentb663b9436e7509b5e73c8c372539f067cd6e66c1
Reverse the search order in afterTriggerAddEvent().

When scanning existing AfterTriggerSharedData records in search
of a match to the event being queued, we were examining the
records from oldest to newest.  But it makes more sense to do
the opposite.  The newest record is likely to be from the current
query, while the oldest is likely to be from some previous command
in the same transaction, which will likely have different details.

There aren't expected to be very many active AfterTriggerSharedData
records at once, so that this change is unlikely to make any
spectacular difference.  Still, having added a nontrivially-expensive
bms_equal call to this loop yesterday, I feel a need to shave cycles
where possible.

Discussion: https://postgr.es/m/4166712.1737583961@sss.pgh.pa.us
src/backend/commands/trigger.c