Re: Jsonb extraction very slow - Mailing list pgsql-general

From Tom Lane
Subject Re: Jsonb extraction very slow
Date
Msg-id 11665.1471360761@sss.pgh.pa.us
Whole thread Raw
In response to Re: Jsonb extraction very slow  (Jim Nasby <Jim.Nasby@BlueTreble.com>)
Responses Re: Jsonb extraction very slow
List pgsql-general
Jim Nasby <Jim.Nasby@BlueTreble.com> writes:
> On 8/11/16 8:45 AM, Tom Lane wrote:
>> What were you doing to "get ten keys out"?  If those were ten separate
>> JSON operators, they'd likely have done ten separate decompressions.
>> You'd have saved something by having the TOAST data already fetched into
>> shared buffers, but it'd still hardly be free.

> Multiple -> or ->> operators, but all operating on the same field (which
> I thought would mean a single datum that would end up detoasted?).

No, that's going to work as I said.  It'd be a useful thing to be able to
amortize the decompression work across multiple references to the field,
but currently there's no way to do that.

[ thinks for a bit... ]  In principle we could have the planner notice
whether there are multiple references to the same Var of a varlena type,
and then cue the executor to do a pre-emptive detoasting of that field
of the input tuple slot.  But it would be hard to avoid introducing some
regressions along with the benefits, I'm afraid.

> Some of these would have been nested ->/->>.

In a chain of functions only the first one would be paying the overhead
we're talking about here; though I'm not sure how efficient the case is
overall in JSONB.

            regards, tom lane


pgsql-general by date:

Previous
From: Jim Nasby
Date:
Subject: Re: Jsonb extraction very slow
Next
From: Joy Arulraj
Date:
Subject: Re: C++ port of Postgres