| От | Thomas Kellerer |
|---|---|
| Тема | Re: fast insert-if-key-not-already-there |
| Дата | |
| Msg-id | g778pk$2rq$1@ger.gmane.org обсуждение исходный текст |
| Ответ на | fast insert-if-key-not-already-there (Patrick Scharrenberg <pittipatti@web.de>) |
| Список | pgsql-sql |
Patrick Scharrenberg, 04.08.2008 17:51: > Hi! > > I have to do much inserts into a database where the key most often is > already there. > My current approach is to query for the key (ip-address), and if the > result is null I do the insert. > For every IP-Address I need the ip_addr_id from the same table. > > [...] > > Now I'm wondering if there is a better solution, since I'm doing ~20 > inserts at once and every time I'm doing single lookup's for the IDs. If you know that most of the time the record is already there, I simply execute the UPDATE, then check how many rows wereupdated. If that returns zero, I'll send the INSERT Regards Thomas
В списке pgsql-sql по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера