Re: DELETE, INSERT vs SELECT, UPDATE || INSERT - Mailing list pgsql-performance

From Tom Lane
Subject Re: DELETE, INSERT vs SELECT, UPDATE || INSERT
Date
Msg-id 19921.1135351800@sss.pgh.pa.us
Whole thread Raw
In response to DELETE, INSERT vs SELECT, UPDATE || INSERT  (Anton Maksimenkov <engineer@hlebprom.ru>)
List 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 by date:

Previous
From: Guido Neitzer
Date:
Subject: Re: Order by behaviour
Next
From: Tom Lane
Date:
Subject: Re: Order by behaviour