thank you Adrian, the background of it is that I have already written the python script that translates Oracle MERGE clause to Postgres INSERT ... ON CONFLICT, but in order to be able to add DELETE part from MERGE i need to distinct those operations. thank you for the idea with trigger, i haven't thought about it at the beginning, but it does complicate the code a lot :/ not saying about performance... -- Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html