Re: Performance impact of updating target columns with unchanged values ON CONFLICT

From: Abi Noda <a(at)abinoda(dot)com>
To: pryzby(at)telsasoft(dot)com
Cc: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: Performance impact of updating target columns with unchanged values ON CONFLICT
Date: 2018-11-24 03:44:37
Message-ID: CAM37AMPT72o-uZP939jWdhN=v4K4dZkN45E4fvaeh63HzK2GKg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Thanks Justin. Do you know if Postgres treats an UPDATE that sets the
indexed columns set to the same previous values as a change? Or does it
only count it as "changed" if the values are different. This is ambiguous
to me.

*> HOT solves this problem for a restricted but useful special case where a
tuple is repeatedly updated in ways that do not change its indexed columns.*

*> With HOT, a new tuple placed on the same page and with all indexed
columns the same as its parent row version does not get new index entries.*

*> [HOT] will create a new physical heap tuple when inserting, and not a
new index tuple, if and only if the update did not affect indexed columns.*

On Thu, Nov 22, 2018 at 2:40 PM Justin Pryzby <pryzby(at)telsasoft(dot)com> wrote:

> On Thu, Nov 22, 2018 at 01:31:10PM -0800, Abi Noda wrote:
> > In other words, is Postgres smart enough to not actually write to disk
> any
> > columns that haven’t changed value or update indexes based on those
> columns?
>
> You're asking about what's referred to as Heap only tuples:
>
> https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/access/heap/README.HOT;hb=HEAD
> https://wiki.postgresql.org/wiki/Index-only_scans#Interaction_with_HOT
>
> Note, if you're doing alot of updates, you should consider setting a lower
> the
> table fillfactor, since HOT is only possible if the new tuple (row
> version) is
> on the same page as the old tuple.
>
> |With HOT, a new tuple placed on the same page and with all indexed
> columns the
> |same as its parent row version does not get new index entries."
>
> And check pg_stat_user_tables to verify that's working as intended.
>
> Justin
>

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Abi Noda 2018-11-24 03:53:14 Re: Performance impact of updating target columns with unchanged values ON CONFLICT
Previous Message Justin Pryzby 2018-11-23 16:10:28 Re: dsa_allocate() faliure