Re: App very unresponsive while performing simple update

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: App very unresponsive while performing simple update
Дата
Msg-id 874pzanvk6.fsf@stark.xeocode.com
обсуждение исходный текст
Ответ на Re: App very unresponsive while performing simple update  (Brendan Duddridge <brendan@clickspace.com>)
Ответы Re: App very unresponsive while performing simple update  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-performance
Brendan Duddridge <brendan@clickspace.com> writes:

> Further to my issue, the update never did finish. I received the  following
> message in psql:
>
> ssprod=# update product set is_hungry = 'true'  where date_modified >
> current_date - 10;
> ERROR:  deadlock detected
> DETAIL:  Process 18778 waits for ShareLock on transaction 711698780;   blocked
> by process 15784.
> Process 15784 waits for ShareLock on transaction 711697098; blocked  by process
> 18778.

What queries are those two processes executing? And what foreign keys do you
have on the product table or elsewhere referring to the product table? And
what indexes do you have on those columns?

I think this indicates you have foreign keys causing the deadlock. One process
is waiting until an update elsewhere finishes before modifying a record that
other update refers to via a foreign key. But that other process is waiting
similarly for the first one.

Do you have any foreign keys in other tables referring to the product table?
Do you have indexes on those other tables? The update needs to check those
other tables to make sure there are no references to the records you're
updating. If there's no index it has to do a sequential scan.

To get a deadlock I think you would need another update running somewhere
though.



--
greg

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

Предыдущее
От: Brendan Duddridge
Дата:
Сообщение: Re: App very unresponsive while performing simple update
Следующее
От: "Cstdenis"
Дата:
Сообщение: Re: How can I make this query faster (resend)