Re: Update on tables when the row doesn't change

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Update on tables when the row doesn't change
Дата
Msg-id 5744.1116969254@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Update on tables when the row doesn't change  (Sebastian Böck <sebastianboeck@freenet.de>)
Ответы Re: Update on tables when the row doesn't change  (Richard Huxton <dev@archonet.com>)
Список pgsql-general
=?ISO-8859-1?Q?Sebastian_B=F6ck?= <sebastianboeck@freenet.de> writes:
> Why does Postgres perform updates to tables, even if the row doesn't
> change at all?

Because testing for this would almost surely be a net loss for the vast
majority of applications.  Checking to see if the new row value exactly
equals the old is hardly a zero-cost operation; if you pay that on every
update, that's a lot of overhead that you are hoping to make back by
sometimes avoiding the physical store of the new tuple.  In most
applications I think the "sometimes" isn't going to be often enough
to justify doing it.

If you have a particular table in a particular app where it is worth it,
I'd recommend writing a BEFORE UPDATE trigger to make the comparisons
and suppress the update when NEW and OLD are equal.

            regards, tom lane

В списке pgsql-general по дате отправления:

Предыдущее
От: Sebastian Böck
Дата:
Сообщение: Re: Update on tables when the row doesn't change
Следующее
От: Dino Vliet
Дата:
Сообщение: reporting solution for postgresql