From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-admin <pgsql-admin@postgresql.org>
Subject: Re: Postgres Updating only changed columns against entire row
Date: Fri, 29 Jul 2022 01:32:53 -0500
Message-ID: <88ffa330-e0e2-f9da-2469-97dbeca66906@gmail.com> (raw)
In-Reply-To: <CAF6DVKMGLnWB4tzWduQXXR8vtyu1DFGi9nh3u++szWZJsvSPTQ@mail.gmail.com>
References: <CAF6DVKMGLnWB4tzWduQXXR8vtyu1DFGi9nh3u++szWZJsvSPTQ@mail.gmail.com>
On 7/29/22 01:19, Debraj Manna wrote:
>
> Let's say I have a table like below
>
> |CREATE TABLE empl( id SERIAL PRIMARY KEY, name VARCHAR NOT NULL, address
> VARCHAR NOT NULL, status int NOT NULL, metadata varchar NOT NULL ); |
>
> and it has data like
>
> |(2, 'tuk', 'ind', 1, 'meta') ... (200, 'tuka', 'eng', 2, 'meta2') |
>
> 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?
>
I'll counter with my own question: why would you go through all the extra
coding effort (which leads to *more places that you can make a mistake*,
like accidentally typing |metadata='meeta'|)?
Also, the parentheses are superfluous in this case.
--
Angular momentum makes the world go 'round.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: ronljohnsonjr@gmail.com
Subject: Re: Postgres Updating only changed columns against entire row
In-Reply-To: <88ffa330-e0e2-f9da-2469-97dbeca66906@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox