Re: Duplicate key insert question
От | Jean-Christian Imbeault |
---|---|
Тема | Re: Duplicate key insert question |
Дата | |
Msg-id | 3F023121.7010209@mega-bucks.co.jp обсуждение исходный текст |
Ответ на | Re: Duplicate key insert question ("Maksim Likharev" <mlikharev@aurigin.com>) |
Ответы |
Re: Duplicate key insert question
|
Список | pgsql-general |
Maksim Likharev wrote: > > Finding if the duplicate value exists and inserting if not. Ok, thanks but I think it is still vulnerable to a race condition. > I do not know how that will work for PG, but in Microsoft SQL Server > you can do following > BEGIN TRANSACTION > UPDATE [val] = [val] > WHERE .... > INSERT ... > COMMIT TRANSACTION > > so basically by updating specific row ( let say you have such row ) > in transaction, row/page lock will be held until end of transaction > and concurrent UPDATE will wait until you are done. > Kind of semaphore. Why the UPDATE? And in postgres every query runs in it's own transaction so no need for the explicit BEGIN / END block. So can't see how your solution is any better than the previous one :) Thanks, Jean-Christian Imbeault
В списке pgsql-general по дате отправления: