Thread: Does update = delete + insert ?
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 !
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°
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 ascript where it would be more expeditious for me to delete/insert a record as opposed to update and want to know if I loseanything 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
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 ascript where it would be more expeditious for me to delete/insert a record as opposed to update and want to know if I loseanything 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