Skip site navigation (1) Skip section navigation (2)

Re: performance: delete+insert versus update

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Lonni J Friedman <netllama(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: performance: delete+insert versus update
Date: 2009-03-31 04:56:09
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Lonni J Friedman <netllama(at)gmail(dot)com> writes:
> I'm in the midst of a heated debate with a coworker over whether doing
> a delete + insert is more expensive than doing an update.  My belief
> is that an update will usually be less expensive.  Can anyone weigh
> in?

Well, in terms of changes hitting the disk, they're approximately
the same thing in Postgres (not so in many other DBs, though).  However,
the overhead of issuing two SQL commands instead of one means that the
update method should win.

If your coworker knows how to do a delete+insert with no more SQL
interpretation than an update, I'd like to see it ...

			regards, tom lane

In response to

pgsql-novice by date

Next:From: bijoy francoDate: 2009-03-31 18:11:33
Subject: OperationalError while using postgresql through python
Previous:From: Lonni J FriedmanDate: 2009-03-31 03:24:32
Subject: performance: delete+insert versus update

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group