Re: Poor performance for delete query

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Poor performance for delete query
Дата
Msg-id 28604.1398371340@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Poor performance for delete query  (Jonatan Evald Buus <jonatan.buus@cellpointmobile.com>)
Ответы Re: Poor performance for delete query  (Jonatan Evald Buus <jonatan.buus@cellpointmobile.com>)
Список pgsql-performance
Jonatan Evald Buus <jonatan.buus@cellpointmobile.com> writes:
> We're currently having very poor performance for the following delete query.
> DELETE FROM TopTable WHERE id IN (xx, yy, zz);

> We've observed that it takes around 7 seconds under normal load to for each
> row that's being from TopTable and several minutes pr deleted row under
> heavy load.

I'd really have to bet that you forgot to index one of the referencing
tables.  Are any of the foreign keys multi-column?  If so you probably
need a matching multi-column index, not just indexes on the individual
referencing columns.

> How do we track down the cause of the poorly performing delete query?

EXPLAIN ANALYZE on a DELETE, for starters.  That would isolate whether
it's the DELETE itself or one of the foreign-key updates, and if the
latter which one.  It's a little bit difficult to see the exact plan being
used for a foreign-key update query, but I think one way you could do it
is to enable auto_explain with auto_explain.log_nested_statements turned
on.

            regards, tom lane


В списке pgsql-performance по дате отправления:

Предыдущее
От: Sergey Konoplev
Дата:
Сообщение: Re: tsearch2, large data and indexes
Следующее
От: Jonatan Evald Buus
Дата:
Сообщение: Re: Poor performance for delete query