Re: updates not causing changes

Поиск
Список
Период
Сортировка
От Jeff Janes
Тема Re: updates not causing changes
Дата
Msg-id CAMkU=1x0SPzEEAj69n3+LtDX-S5qF4nUgXd36K5tt5JjL4bjqA@mail.gmail.com
обсуждение исходный текст
Ответ на updates not causing changes  (Torsten Förtsch <torsten.foertsch@gmx.net>)
Список pgsql-general
On Thu, Jun 12, 2014 at 10:22 AM, Torsten Förtsch <torsten.foertsch@gmx.net> wrote:
Hi,

our developers use a ORM tool which generates updates that write all
columns of a table. In most cases, however, very few columns actually
change. So, those updates mostly write the same value that already is
there in the column.

Now, if there is an index on such columns, does Postgres recognize the
situation and skip the index update?

If any indexed column changes, than all indexes need to be updated, because the tuple will get a new ctid and that is part of each index.  If no indexed columns change (and the new column fits in the same page), then it can use HOT update and avoid the index maintenance.

For purposes of determining if an indexed column changes, it compares the old value to the new value.  It doesn't matter whether the column was updated in a degenerate way, or if it was not in the update list in the first place--either way the lack-of-change is detected.

Cheers,

Jeff

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

Предыдущее
От: Merlin Moncure
Дата:
Сообщение: Re: max_connections reached in postgres 9.3.3
Следующее
От: Jerry Sievers
Дата:
Сообщение: Re: what does pg_activity mean when the database is stuck?