Postgres: updating unchanged rows

Let's say I have the following query:

UPDATE table_name SET column_name1 = column_value1, ..., column_nameN = column_valueN WHERE id = M 

The fact is that column_value1, ..., column_valueN have not changed. Will this query really be executed, and what about performance in this case compared to updating with really modified data? What should I do if I have about 50 such requests on a page with unchanged data?

+4
source share
1 answer

You need to help postgresql here by specifying only the modified columns and rows. It will work and perform an update according to all your instructions without checking whether the data has been changed.

ps Here ORM comes in handy.

EDIT: You may also be interested in How to speed up update / replace operations in PostgreSQL? where the OP overcame all the problems in order to accelerate UPDATE performance, when the best performance can be achieved by updating only the changed data.

+4
source

All Articles