pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: D'Arcy J.M. Cain <darcy@druid.net>
To: Dave Dutcher <dave@tridecap.com>
Cc: lists@peufeu.com
Cc: pgsql-performance@postgresql.org
Subject: Re: INSERT OU UPDATE WITHOUT SELECT?
Date: Tue, 30 May 2006 19:05:08 -0400
Message-ID: <20060530190508.aa47bafe.darcy@druid.net> (raw)
In-Reply-To: <039201c6843b$f11eeaf0$8300a8c0@tridecap.com>
References: <op.tadyc1jwcigqcu@apollo13>
	<039201c6843b$f11eeaf0$8300a8c0@tridecap.com>

On Tue, 30 May 2006 17:54:00 -0500
"Dave Dutcher" <dave@tridecap.com> wrote:
> What I do when I'm feeling lazy is execute a delete statement and then
> an insert.  I only do it when I'm inserting/updating a very small number
> of rows, so I've never worried if its optimal for performance.  Besides
> I've heard that an update in postgres is similar in performance to a
> delete/insert.

Well, they are basically the same operation in PostgreSQL.  An update
adds a row to the end and marks the old one dead.  A delete/insert
marks the row dead and adds one at the end.  There may be some
optimization if the engine does both in one operation.

-- 
D'Arcy J.M. Cain <darcy@druid.net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.



view thread (7+ messages)  latest in thread

Message-ID: <20060530190508.aa47bafe.darcy@druid.net>
Permalink:  ../20060530190508.aa47bafe.darcy@druid.net/
Also on:    postgresql.org/message-id/20060530190508.aa47bafe.darcy@druid.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: darcy@druid.net, dave@tridecap.com, lists@peufeu.com
  Subject: Re: INSERT OU UPDATE WITHOUT SELECT?
  In-Reply-To: <20060530190508.aa47bafe.darcy@druid.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox