Re: Select for update, locks and transaction levels

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Select for update, locks and transaction levels
Дата
Msg-id 6162.1076985752@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Select for update, locks and transaction levels  ("Nick Barr" <nick.barr@webbased.co.uk>)
Список pgsql-general
"Nick Barr" <nick.barr@webbased.co.uk> writes:
> I personally did not like the look of 1 so I thought about using 2. The
> main reason being there would be no locks that would interfere with
> "updating" the view count because in fact this was just an INSERT
> statement.

INSERTs are good.

> Q2.Will a "group by" used with a "select . for update" lock all the rows
> used for the sum?

No; it won't work at all.

regression=# select hundred,count(*) from tenk1 group by hundred for update;
ERROR:  SELECT FOR UPDATE is not allowed with GROUP BY clause
regression=#

However, AFAICS it will not matter if you are using a serializable
transaction.  If two such transactions try to delete the same row,
one of them will error out, so you do not need FOR UPDATE.

            regards, tom lane

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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: Fosdem
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Cascade delete triggers change user credentials