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)
Ответы: Re: how to efficiently update tuple in many-to-many relationship?  (Drew Wilson)
Список: pgsql-performance

Скрыть дерево обсуждения

how to efficiently update tuple in many-to-many relationship?  (Drew Wilson, )
 Re: how to efficiently update tuple in many-to-many relationship?  ("Merlin Moncure", )
 Re: how to efficiently update tuple in many-to-many relationship?  (Tom Lane, )
  Re: how to efficiently update tuple in many-to-many relationship?  (Drew Wilson, )
   Re: how to efficiently update tuple in many-to-many relationship?  (Tom Lane, )
    Re: how to efficiently update tuple in many-to-many relationship?  (Drew Wilson, )
     Re: how to efficiently update tuple in many-to-many relationship?  (Tom Lane, )
      Re: how to efficiently update tuple in many-to-many relationship?  (Drew Wilson, )
       Re: how to efficiently update tuple in many-to-many relationship?  (Tom Lane, )
        Question about memory allocations  (Steve, )
         Re: Question about memory allocations  (Tom Lane, )
          Re: Question about memory allocations  (Steve, )
         Re: Question about memory allocations  (Greg Smith, )
          Re: Question about memory allocations  (Steve, )
         Re: Question about memory allocations  (Andrew McMillan, )
          Re: Question about memory allocations  (Steve, )
           Re: Question about memory allocations  (Ron, )
            Re: Question about memory allocations  (Tom Lane, )
           Re: Question about memory allocations  (Carlos Moreno, )
            Re: Question about memory allocations  ("Jan de Visser", )

Drew Wilson <> 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?
От: "Merlin Moncure"
Дата:
Сообщение: Re: join to view over custom aggregate seems like it should be faster