pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dmitry Dolgov <9erthalion6@gmail.com>
Cc: Mitar <mmitar@gmail.com>
Cc: pgsql-general@postgresql.org
Subject: Re: Why is writing JSONB faster than just JSON?
Date: Thu, 15 Apr 2021 12:47:25 -0400
Message-ID: <3785442.1618505245@sss.pgh.pa.us> (raw)
In-Reply-To: <20210415154311.t3meozbednmsfhxx@localhost>
References: <CAKLmikORKREgCE8F69NUcbi6aSo-ZrU75P0Jb8adaqpEVqS0Kg@mail.gmail.com>
	<20210414084845.rkbe525twb4jr4fw@localhost>
	<3488585.1618410383@sss.pgh.pa.us>
	<20210415154311.t3meozbednmsfhxx@localhost>

Dmitry Dolgov <9erthalion6@gmail.com> writes:
> On Wed, Apr 14, 2021 at 10:26:23AM -0400, Tom Lane wrote:
>> My own guess about this, without having tried to reproduce it, is that
>> JSONB might end up physically smaller than JSON, resulting in less work
>> to push the toasted datum out to disk.  This'd depend a lot on your
>> formatting habits for JSON, of course.  But in any case, it'd be worth
>> comparing pg_column_size() results to see what's up with that.

> Oh, of course I've missed that the input I was using was indeed
> formatted, without formatting both cases perform equally well and I
> can't reproduce the issue. Although if I understand correctly the
> original code in question doesn't actually do any formatting.

My point was that for JSON, after validating that the input is
syntactically correct, we just store it as-received.  So in particular
the amount of whitespace in the value would depend on how the client
had chosen to format the JSON.  This'd affect the stored size of
course, and I think it would have an effect on compression time too.

			regards, tom lane





view thread (12+ messages)  latest in thread

Message-ID: <3785442.1618505245@sss.pgh.pa.us>
Permalink:  ../3785442.1618505245@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3785442.1618505245@sss.pgh.pa.us

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, 9erthalion6@gmail.com, mmitar@gmail.com
  Subject: Re: Why is writing JSONB faster than just JSON?
  In-Reply-To: <3785442.1618505245@sss.pgh.pa.us>
  References: <CAKLmikORKREgCE8F69NUcbi6aSo-ZrU75P0Jb8adaqpEVqS0Kg@mail.gmail.com> <20210414084845.rkbe525twb4jr4fw@localhost> <3488585.1618410383@sss.pgh.pa.us> <20210415154311.t3meozbednmsfhxx@localhost> <3785442.1618505245@sss.pgh.pa.us>

* 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