Re: how to efficiently update tuple in many-to-many relationship?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: how to efficiently update tuple in many-to-many relationship?
Дата
Msg-id 16374.1176171185@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: how to efficiently update tuple in many-to-many relationship?  (Drew Wilson <drewmwilson@gmail.com>)
Ответы Re: how to efficiently update tuple in many-to-many relationship?  (Drew Wilson <drewmwilson@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Drew Wilson
Дата:
Сообщение: Re: how to efficiently update tuple in many-to-many relationship?
Следующее
От: Drew Wilson
Дата:
Сообщение: Re: how to efficiently update tuple in many-to-many relationship?