Re: DELETE, INSERT vs SELECT, UPDATE || INSERT

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: DELETE, INSERT vs SELECT, UPDATE || INSERT
Дата
Msg-id 19921.1135351800@sss.pgh.pa.us
обсуждение исходный текст
Ответ на DELETE, INSERT vs SELECT, UPDATE || INSERT  (Anton Maksimenkov <engineer@hlebprom.ru>)
Список pgsql-performance
Anton Maksimenkov <engineer@hlebprom.ru> writes:
>  Second idea was to try to SELECT (user, cookie) pair and then UPDATE
> it if it exists or INSERT if not. I has thought that if UPDATE will
> rewrite same place in file with new count it may lead to more compact
> table (file not grow and information about actual rows in file will
> not changed).

You're wasting your time, because Postgres doesn't work that way.
UPDATE is really indistinguishable from DELETE+INSERT, and there will
always be a dead row afterwards, because under MVCC rules both versions
of the row have to be left in the table for some time after your
transaction commits.  See
http://www.postgresql.org/docs/8.1/static/mvcc.html

            regards, tom lane

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

Предыдущее
От: Guido Neitzer
Дата:
Сообщение: Re: Order by behaviour
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Order by behaviour