Re: Postgres Updating only changed columns against entire row

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday, July 28, 2022, Debraj Manna <subharaj.manna@xxxxxxxxx> 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.


[Index of Archives]     [Postgresql Home]     [Postgresql General]     [Postgresql Performance]     [Postgresql PHP]     [Postgresql Jobs]     [PHP Users]     [PHP Databases]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Forum]

  Powered by Linux