Does update = delete + insert ?

Started by Gauthier, Davealmost 16 years ago4 messagesgeneral
Jump to latest
#1Gauthier, Dave
dave.gauthier@intel.com

Hi:

Under the hood, does PG implement an update statement as a delete followed by an insert? I'm at a point in coding a script where it would be more expeditious for me to delete/insert a record as opposed to update and want to know if I lose anything by doing that.

Thanks in Advance !

#2Andreas Kretschmer
akretschmer@spamfence.net
In reply to: Gauthier, Dave (#1)
Re: Does update = delete + insert ?

Gauthier, Dave <dave.gauthier@intel.com> wrote:

Hi:

Under the hood, does PG implement an update statement as a delete followed by
an insert? I’m at a point in coding a script where it would be more

Yes, Update means delete the old record and create a new one.

Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknown)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°

#3Steve Atkins
steve@blighty.com
In reply to: Gauthier, Dave (#1)
Re: Does update = delete + insert ?

On May 26, 2010, at 11:41 AM, Gauthier, Dave wrote:

Hi:

Under the hood, does PG implement an update statement as a delete followed by an insert? I’m at a point in coding a script where it would be more expeditious for me to delete/insert a record as opposed to update and want to know if I lose anything by doing that.

As far as writes to the table are concerned, yes they're pretty much the same.

If there are triggers on the table, though, they may see the two actions differently.

Cheers,
Steve

#4Gauthier, Dave
dave.gauthier@intel.com
In reply to: Steve Atkins (#3)
Re: Does update = delete + insert ?

Ohhhh.. Yes, I forgot about the triggers.
Good call !!! This table has lots of triggers.

Thanks for reminding me of this!!!

-----Original Message-----
From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Steve Atkins
Sent: Wednesday, May 26, 2010 3:05 PM
To: pgsql-general General
Subject: Re: [GENERAL] Does update = delete + insert ?

On May 26, 2010, at 11:41 AM, Gauthier, Dave wrote:

Hi:

Under the hood, does PG implement an update statement as a delete followed by an insert? I'm at a point in coding a script where it would be more expeditious for me to delete/insert a record as opposed to update and want to know if I lose anything by doing that.

As far as writes to the table are concerned, yes they're pretty much the same.

If there are triggers on the table, though, they may see the two actions differently.

Cheers,
Steve
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general