Merge statement in Yugabyte

Does Yugabyte supports Merge statement with Insert, update & delete?


PostgreSQL introduced support for the MERGE statement in version 15. YugabyteDB, on the other hand, currently uses PostgreSQL version 11.2, so the answer, if I understood your question correctly, would be no, it doesn’t support the MERGE statement yet.

However, upgrading to PostgreSQL 15 is in the roadmap, being worked on for the upcoming release of YugabyteDB version 2.21 (latest stable version is 2.20). See more information here: Upgrade to PostgreSQL 15 · Issue #9797 · yugabyte/yugabyte-db · GitHub

You can use a WITH clause with RETURNING to implement your merge logic. It has the advantage of processing rows in sets and YugabyteDB batches those operations to reduce latency. Some examples here:
UPSERT some columns in YugabyteDB (ON CONFLICT DO UPDATE) - DEV Community