Re: [ADMIN] Some questions on PostgreSQL 9.6 JSONB - Mailing list pgsql-admin

From Wei Shan
Subject Re: [ADMIN] Some questions on PostgreSQL 9.6 JSONB
Date
Msg-id CAFe9ZTr2_cPQ80AmRRvHmjoX3BgEV8KSYyBcpMUSBZqbvucFOg@mail.gmail.com
Whole thread Raw
In response to Re: [ADMIN] Some questions on PostgreSQL 9.6 JSONB  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: [ADMIN] Some questions on PostgreSQL 9.6 JSONB
List pgsql-admin
Stupid question really,

If I have to specify the entire JSON value, this means that the update query replaces the entire row instead of updating a single field. Is this correct?

On 28 August 2017 at 16:20, David G. Johnston <david.g.johnston@gmail.com> wrote:
On Mon, Aug 28, 2017 at 7:06 AM, Keith <keith@keithf4.com> wrote:
On Mon, Aug 28, 2017 at 9:46 AM, Wei Shan <weishan.ang@gmail.com> wrote:
Is this the most efficient way to do it? I'm not sure because this is basically replacing the entire JSON object instead of updating a single field.


keith@keith=# UPDATE json_data SET data = jsonb_set(data, '{account_balance}', '1'::jsonb, false);

​This.  Note still that in a MVCC (multi-version concurrency controlling) database you never really just update something in place since the old something has to continue to exist at the same time as the new something - at least for a little while.

David J.​



--
Regards,
Ang Wei Shan

pgsql-admin by date:

Previous
From: Aleksander Kamenik
Date:
Subject: [ADMIN] Re: pg_current_xlog*_location and pg_stat_replication.replay_location> 0 for synced replication connection
Next
From: "David G. Johnston"
Date:
Subject: Re: [ADMIN] Some questions on PostgreSQL 9.6 JSONB