Re: Optimizing bulk update performance

From: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Optimizing bulk update performance
Date: 2013-04-28 04:16:54
Message-ID: kli7rm$n6r$1@gonzo.reversiblemaps.ath.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2013-04-27, Yang Zhang <yanghatespam(at)gmail(dot)com> wrote:
> On Sat, Apr 27, 2013 at 1:55 AM, Misa Simic <misa(dot)simic(at)gmail(dot)com> wrote:

>> Optionaly you can run vacuum analyze after bulk operation...
>
> But wouldn't a bulk UPDATE touch many existing pages (say, 20%
> scattered around) to mark rows as dead (per MVCC)? I guess it comes
> down to: will PG be smart enough to mark dead rows in largely
> sequential scans (rather than, say, jumping around in whatever order
> rows from foo are yielded by the above join)?

A plpgsql FOR-IN-query loop isn't going to be that smart, it's a
procedural language ans does things procedurally, if you want to do
set operations use SQL.

this:

UPDATE existing-table SET .... FROM temp-table WHERE join-condition;

will likely get you a sequential scan over the existing table

and should be reasonably performant as long as temp-table is small
enough to fit in memory.

--
⚂⚃ 100% natural

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jasen Betts 2013-04-28 04:49:30 Re: regex help wanted
Previous Message Tom Lane 2013-04-28 03:03:26 Re: DISTINCT ON changes sort order on its own it seems