| От | 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 по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера