Re: Postgres Updating only changed columns against entire row

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Postgres Updating only changed columns against entire row
Дата
Msg-id CAKFQuwbkiGUnX8RxQuQRwfYSGXBT5NuhJhsEwJDx3wZcG8_LMQ@mail.gmail.com
обсуждение исходный текст
Ответ на Postgres Updating only changed columns against entire row  (Debraj Manna <subharaj.manna@gmail.com>)
Список pgsql-admin
On Thursday, July 28, 2022, Debraj Manna <subharaj.manna@gmail.com> wrote:

  1. update empl set status = 2 where (id = 2);
  2. update empl set status = 2, name='tuk', address='ind', metadata='meta' where (id = 2);

Can someone let me know if there are any advantages of doing #1 over #2 assuming there are no other indices or triggers on the table? Which is generally preferred?

Neither…

You’d write:  update empl set status = $1, name = $2, … where id = $N;

Then assign some variables in your code to $1, $2, etc…

By having a parameter for each field one query can deal with changes to any of the data elements.

 

Postgres Version - 10.17


That doesn’t seem relevant, this is a theory question. 

David J.

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

Предыдущее
От: Holger Jakobs
Дата:
Сообщение: Re: pg 12 \if unwanted message
Следующее
От: Mladen Gogala
Дата:
Сообщение: Re: Oracle data to PG