Question: I have a performance-related question. Let's say I have a user with first name Michael. Take the following query:

```
UPDATE users
SET first_name = 'Michael'
WHERE users.id = 123

```

Will the query actually execute the update, even though it is being updated to the same value? If so, how do I prevent it from happening?

Answer: 
ORM's like Ruby on Rail's offer deferred execution which mark a record as changed (or not) and then when needed or called, then submit the change to the database.

PostgreSQL is a database and not an ORM. It would have decreased performance if it took the time to check if a new value was the same as the updated value in your query.

It will therefore update the value regardless of whether it is the same as the new value or not.

If you wish to prevent this, you could use code like Max Vernon suggested in his answer.
You could simply add to the `where` clause:

```
UPDATE users
SET first_name = 'Michael'
WHERE users.id = 123
    AND (first_name <> 'Michael' OR first_name IS NULL);

```

If `first_name` is defined as `NOT NULL`, the `OR first_name IS NULL` part can be removed.

The condition: 

```
(first_name <> 'Michael' OR first_name IS NULL)

```

can also be written more elegantly as (in Erwin's answer):

```
first_name IS DISTINCT FROM 'Michael'

```