Re: Is full-row updates slower than single-value updates

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Björn Lindqvist <bjourne(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Is full-row updates slower than single-value updates
Date: 2010-06-28 17:59:09
Message-ID: AANLkTile5YXjDC5zVaG8NMUk_7dD2gvI2ZHYZGC9aMqb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello

2010/6/28 Björn Lindqvist <bjourne(at)gmail(dot)com>:
> Hello everyone,
>
> My question is like the subject, is it much slower to update all
> columns values than just a single column? Generated update queries
> from ORM:s generally have the following format:
>
> update foo set a = 1, b = 2, c = 3, .... where id = 1234;
>
> So each column is touched which, I suspect, is much slower than just
> updating a single column because more indexes has to be rebuilt and so
> on. EXPLAIN ANALYZE does not give any hints and claims that both
> queries are equally fast. Maybe someone can guide me to documentation
> which explains how to estimate how costly row-level updates are?
>

it depends. Pg create a new version of complete row for every update,
so isn't important if you update one or all columns. But there are
exception - TOAST columns. If you update any TOAST column, then UPDATE
is significally slower, so - if you don't need to update these
columns, then don't do it.

Regards

Pavel

> --
> mvh Björn
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Geoffrey Myers 2010-06-28 18:11:37 weird initdb output
Previous Message Konstantin Izmailov 2010-06-28 17:21:25 Re: PQprepare in PostgreSQL 7.4 (lack of SAVEPOINTs)