Re: how to efficiently update tuple in many-to-many relationship? - Mailing list pgsql-performance

From Tom Lane
Subject Re: how to efficiently update tuple in many-to-many relationship?
Date
Msg-id 16374.1176171185@sss.pgh.pa.us
Whole thread Raw
In response to Re: how to efficiently update tuple in many-to-many relationship?  (Drew Wilson <drewmwilson@gmail.com>)
Responses Re: how to efficiently update tuple in many-to-many relationship?
List pgsql-performance
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

pgsql-performance by date:

Previous
From: Drew Wilson
Date:
Subject: Re: how to efficiently update tuple in many-to-many relationship?
Next
From: Drew Wilson
Date:
Subject: Re: how to efficiently update tuple in many-to-many relationship?