Re: Implementing replace function

Поиск
Список
Период
Сортировка
От Matthieu Huin
Тема Re: Implementing replace function
Дата
Msg-id 4CCFDE02.3010708@wallix.com
обсуждение исходный текст
Ответ на Re: Implementing replace function  (Thomas Kellerer <spam_eater@gmx.net>)
Ответы Re: Implementing replace function  (Martijn van Oosterhout <kleptog@svana.org>)
Список pgsql-general
Hello,

If you expect your data to reach some kind of "critical size" at some
point ( ie updates will be more likely than inserts at that point ), you
can optimize your UPSERT code by trying to UPDATE before INSERTing.
Otherwise trying to INSERT first should decrease the average UPSERT
execution time in the long run, since you are less likely to hit the
exception and do some extra work on the table.

Anyway, glad to hear this is going to be accounted for in 9.1 . :)

Le 31/10/2010 11:07, Thomas Kellerer a écrit :
> Alexander Farber wrote on 31.10.2010 09:22:
>> Hello Postgres users,
>>
>> to mimic the MySQL-REPLACE statement I need
>> to try to UPDATE a record and if that fails - INSERT it.
>>
>
> There is actually an example of this in the PG manual ;)
>
> http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE
>
>
> Here is another solution based on triggers:
> http://database-programmer.blogspot.com/2009/06/approaches-to-upsert.html
>
> Regards
> Thomas
>
>


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

Предыдущее
От: Andreas 'ads' Scherbaum
Дата:
Сообщение: [ANNOUNCE] PostgreSQL@FOSDEM 2011 - Call for talks
Следующее
От: Tom Lane
Дата:
Сообщение: Re: index in desc order