From: | Kevin Grittner <kgrittn(at)gmail(dot)com> |
---|---|
To: | Gasper Zejn <zelo(dot)zejn(at)gmail(dot)com> |
Cc: | "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Proposal for UPDATE: do not insert new tuple on heap if update does not change data |
Date: | 2016-01-20 17:26:39 |
Message-ID: | CACjxUsNp0bMvVp5oRpFNsDWXQ7jkcy4rCKzDFrbXgU76LBq8Fw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Jan 20, 2016 at 3:55 AM, Gasper Zejn <zelo(dot)zejn(at)gmail(dot)com> wrote:
> I was wondering if PostgreSQL adds new tuple if data is not changed
> when using UPDATE. It turns out it does add them and I think it might
> be beneficial not to add a new tuple in this case, since it causes a
> great deal of maintenance: updating indexes, vacuuming table and
> index, also heap fragmentation.
If you have one or more tables on which you routinely updated rows
to the values they already have, you might want to attach an update
trigger using the suppress_redundant_updates_trigger() function.
http://www.postgresql.org/docs/current/interactive/functions-trigger.html
A better solution, where possible, is to use the WHERE clause to
avoid the update attempt where the new values are not distinct from
the old ones.
--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
From | Date | Subject | |
---|---|---|---|
Next Message | Joel Jacobson | 2016-01-20 17:31:58 | Re: Releasing in September |
Previous Message | Andres Freund | 2016-01-20 17:25:14 | Re: Releasing in September |