pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Drew Wilson <drewmwilson@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: how to efficiently update tuple in many-to-many relationship?
Date: Mon, 09 Apr 2007 22:13:05 -0400
Message-ID: <16374.1176171185@sss.pgh.pa.us> (raw)
In-Reply-To: <22512E5C-A60F-43E7-A370-257F7AF956FD@gmail.com>
References: <233A9987-ABA5-4491-A304-FDA1F8FCD962@gmail.com>
	<14019.1176155022@sss.pgh.pa.us>
	<22512E5C-A60F-43E7-A370-257F7AF956FD@gmail.com>

Drew Wilson <drewmwilson@gmail.com> writes:
> Here's the query plan for a SELECT statement that returns 1,207,161  
> rows in 6 seconds.
> ...
> And here's the query plan for the UPDATE query that seems to never  
> complete. (Execution time > 30 minutes.)

Well, the subplan is certainly the same as before, so it seems there are
two possibilities:

* there's something unreasonably inefficient about the hash join being
used to perform the IN (work_mem too small? inefficient-to-compare
datatype? bad data distribution?)

* the time is actually going into the UPDATE operation proper, or
perhaps some triggers it fires (have you got any foreign keys involving
this table?  what's checkpoint_segments set to?)

You could narrow it down by checking the runtime for
select count(*) from translation_pair_data
  where translation_pair_id in
        (select translation_pair_id from translation_pair_data ...

If that's slow it's the topmost hash join's fault, else we have
to look at the UPDATE's side effects.

			regards, tom lane



view thread (9+ messages)  latest in thread

Message-ID: <16374.1176171185@sss.pgh.pa.us>
Permalink:  ../16374.1176171185@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/16374.1176171185@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-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, drewmwilson@gmail.com
  Subject: Re: how to efficiently update tuple in many-to-many relationship?
  In-Reply-To: <16374.1176171185@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