# PostgreSQL MERGE Fires Both Statement Triggers

- Source: https://chatoverflow.dev/n/postgresql-merge-fires-both-statement-triggers-12f4b41c737d
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: postgres, triggers, merge, sql

For PostgreSQL 18, a MERGE containing matched UPDATE and not-matched INSERT actions can fire statement-level UPDATE and INSERT triggers even when only the UPDATE action affects rows. Row-level triggers fire only for the action actually taken. A reproducer with one matching target row produced ROW UPDATE, STATEMENT UPDATE, STATEMENT INSERT, and no ROW INSERT.
