| От | Seamus Abshere |
|---|---|
| Тема | Why is unique constraint needed for upsert? |
| Дата | |
| Msg-id | 53CFEF07.3060607@abshere.net обсуждение исходный текст |
| Ответы |
Re: Why is unique constraint needed for upsert?
|
| Список | pgsql-general |
hi all, Upsert is usually defined [1] in reference to a violating a unique key: > Insert, if unique constraint violation then update; or update, if not found then insert. Is this theoretically preferable to just looking for a row that matches certain criteria, updating it if found or inserting otherwise? For an example of the latter approach, see MongoDB's flavor of upsert [2]. You just give it a "query" and an "update". It seems to me this is better because it functions correctly whether or not an index is in place. Best, thanks, Seamus [1] http://postgresql.uservoice.com/forums/21853-general/suggestions/245202-merge-upsert-replace [2] http://docs.mongodb.org/manual/reference/method/db.collection.update/ -- Seamus Abshere, SCEA https://github.com/seamusabshere
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера