Disclosed are systems and methods for optimization and efficient
processing of MERGE statements. MERGE allows performing a mix of inserts,
updates, and deletes in a single statement, and introduces new challenges
compared to legacy DML statements, where the kind of action to be
performed is hard-coded and known at compile time. Such optimizations may
include Halloween Protection detection for MERGE statements, optimized
prevention of non-deterministic MERGE statements, in-place inserts for
MERGE statements scanning the "Read Instance" of the target table, and
optimized execution of MERGE statements seeking the "Read Instance" of
the target table. Such optimizations may be fundamental in order to
ensure proper performance and reliable processing times.