Re: how to avoid deadlock on masive update with multiples delete

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: how to avoid deadlock on masive update with multiples delete
Дата
Msg-id 10891.1349454061@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: how to avoid deadlock on masive update with multiples delete  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-performance
Merlin Moncure <mmoncure@gmail.com> writes:
> Can't it be forced like this (assuming it is in fact a vanilla order
> by problem)?

> EXPLAIN DELETE FROM test USING (SELECT g FROM test ORDER BY
> ctid FOR UPDATE) x where x.g = test.g;

> (emphasis on 'for update')

Hm ... yeah, that might work, once you redefine the problem as "get the
row locks in a consistent order" rather than "do the updates in a
consistent order".  But I'd be inclined to phrase it as

EXPLAIN DELETE FROM test USING (SELECT ctid FROM test ORDER BY
g FOR UPDATE) x where x.ctid = test.ctid;

I'm not sure that "ORDER BY ctid" is really very meaningful here; think
about FOR UPDATE switching its attention to updated versions of rows.

            regards, tom lane


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

Предыдущее
От: Claudio Freire
Дата:
Сообщение: Re: how to avoid deadlock on masive update with multiples delete
Следующее
От: Andres Freund
Дата:
Сообщение: Re: how to avoid deadlock on masive update with multiples delete