X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 5702B9FA5E9 for ; Tue, 30 May 2006 20:05:23 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 29391-03 for ; Tue, 30 May 2006 20:05:13 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from druid.net (druid.net [66.96.28.249]) by postgresql.org (Postfix) with ESMTP id 6EA0F9FA5E1 for ; Tue, 30 May 2006 20:05:13 -0300 (ADT) Received: from dilbert (H245.C18.B96.tor.eicat.ca [66.96.18.245]) by druid.net (Postfix) with SMTP id BAD41B483; Tue, 30 May 2006 19:05:12 -0400 (EDT) Date: Tue, 30 May 2006 19:05:08 -0400 From: "D'Arcy J.M. Cain" To: "Dave Dutcher" Cc: lists@peufeu.com, pgsql-performance@postgresql.org Subject: Re: INSERT OU UPDATE WITHOUT SELECT? Message-Id: <20060530190508.aa47bafe.darcy@druid.net> In-Reply-To: <039201c6843b$f11eeaf0$8300a8c0@tridecap.com> References: <039201c6843b$f11eeaf0$8300a8c0@tridecap.com> X-Mailer: Sylpheed version 2.2.4 (GTK+ 2.8.12; i386--netbsdelf) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/557 X-Sequence-Number: 19344 On Tue, 30 May 2006 17:54:00 -0500 "Dave Dutcher" 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 | 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.