Performance of Postgresql Merge vs Insert & Update statements

I would like to know will my performance of my SP’s written in postgresql is going to improve if I move my insert and update statement to the merge statement or it will hamper the performance.

Also if you can provide any official/trustworthy link on the same would be really appreciable.

Just FYI, I am using Postgresql in AWS Aurora Serverless.

Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
April 6, 2022

Hi there,

The main benefit of using a MERGE statement is that it offers some convenience over the traditional INSERT and UPDATE statements as you don’t have to worry about transactions with error handling.

However, if you are mainly after performance, then it is best to stick to INSERT and UPDATE statements.

Of course, it is best to test this for your application-specific needs and figure out how it affects your queries that might be specific to your application and data.

Hope that this helps!