Re: WIP Patch: Add a function that returns binary JSONB as a bytea

Stephen Frost <sfrost@snowman.net>

From: Stephen Frost <sfrost@snowman.net>
To: Merlin Moncure <mmoncure@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Andres Freund <andres@anarazel.de>, Andrew Dunstan <andrew.dunstan@2ndquadrant.com>, kevinvan@shift.com, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2018-11-02T16:15:47Z
Lists: pgsql-hackers
Greetings,

* Merlin Moncure (mmoncure@gmail.com) wrote:
> On Fri, Nov 2, 2018 at 10:53 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > Andres' point about alignment is a pretty good one as well, if it applies
> > here --- I don't recall just what internal alignment requirements jsonb
> > has.  We have not historically expected clients to have to deal with that.
> 
> I see your (and Andres') point; the binary wire format ought to lay on
> top of the basic contracts established by other types.  It can be
> binary; just not a straight memcpy out of the server.  The array and
> composite type serializers should give some inspiration there on
> serialization.

Right- I agree w/ Tom and Andres on this part also.

> I'll still stand other point I made though; I'd
> really want to see some benchmarks demonstrating benefit over
> competing approaches that work over the current formats.  That should
> frame the argument as to whether this is a good idea.

What are the 'competing approaches' you're alluding to here?  Sending
text-format json across as we do today?  Is there something else you're
thinking would be appropriate in this kind of a performance bake-off...?
I'm having a hard time seeing what else would actually have the
flexibility that JSON does without being clearly worse (xml?).

Thanks!

Stephen

Commits

  1. Build de-escaped JSON strings in larger chunks during lexing