pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ken <postgres@kwasnicki.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: update query taking 24+ hours
Date: Sun, 14 Jan 2007 14:30:32 -0500
Message-ID: <12574.1168803032@sss.pgh.pa.us> (raw)
In-Reply-To: <45A9CEA3.3020903@kwasnicki.com>
References: <45A9CEA3.3020903@kwasnicki.com>

Ken <postgres@kwasnicki.com> writes:
> I have postgres 8.1 on a linux box: 2.6Ghz P4, 1.5GB ram, 320GB hard 
> drive.  I'm performing an update between two large tables and so far 
> it's been running for 24+ hours.
> UPDATE Master SET val2=Import.val WHERE Master.x=Import.x AND 
> Master.y=Import.y;

What does EXPLAIN say about that?  (Don't try EXPLAIN ANALYZE,
but a plain EXPLAIN should be quick enough.)

> Both tables have indexes on the x and y columns.  Will that help?

A two-column index would have helped a lot more, probably, although
with so many rows to process I'm not sure that indexes are useful
anyway.  For really bulk updates a hashjoin or sort-and-mergejoin
plan is probably the best bet.

BTW, both of those would require plenty of work_mem to run fast
... what have you got work_mem set to?

And possibly even more to the point, do you have any foreign key
constraints leading into or out of the Master table?

			regards, tom lane



view thread (3+ messages)  latest in thread

Message-ID: <12574.1168803032@sss.pgh.pa.us>
Permalink:  ../12574.1168803032@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/12574.1168803032@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, postgres@kwasnicki.com
  Subject: Re: update query taking 24+ hours
  In-Reply-To: <12574.1168803032@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox