Re: WIP Patch: Add a function that returns binary JSONB as a bytea
От | Andrew Dunstan |
---|---|
Тема | Re: WIP Patch: Add a function that returns binary JSONB as a bytea |
Дата | |
Msg-id | 841bfe52-2b9a-2d6e-50c2-3b3145a6dc3a@2ndQuadrant.com обсуждение исходный текст |
Ответ на | Re: WIP Patch: Add a function that returns binary JSONB as a bytea (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: WIP Patch: Add a function that returns binary JSONB as a bytea
|
Список | pgsql-hackers |
On 10/31/2018 10:21 AM, Tom Lane wrote: > Stephen Frost <sfrost@snowman.net> writes: >> * Tom Lane (tgl@sss.pgh.pa.us) wrote: >>> I dunno, I do not think it's a great idea to expose jsonb's internal >>> format to the world. We intentionally did not do that when the type >>> was first defined --- that's why its binary I/O format isn't already >>> like this --- and I don't see that the tradeoffs have changed since then. >> I disagree- it's awfully expensive to go back and forth between string >> and a proper representation. > Has anyone put any effort into making jsonb_out() faster? I think that > that would be way more productive. Nobody is going to want to write > code to convert jsonb's internal form into whatever their application > uses; particularly not dealing with numeric fields. > > In any case, the approach proposed in this patch seems like the worst > of all possible worlds: it's inconsistent and we get zero benefit from > having thrown away our information-hiding. If we're going to expose the > internal format, let's just change the definition of the type's binary > I/O format, thereby getting a win for purposes like COPY BINARY as well. > We'd need to ensure that jsonb_recv could tell whether it was seeing the > old or new format, but at worst that'd require prepending a header of > some sort. (In practice, I suspect we'd end up with a wire-format > definition that isn't exactly the bits-on-disk, but something easily > convertible to/from that and more easily verifiable by jsonb_recv. > Numeric subfields, for instance, ought to match the numeric wire > format, which IIRC isn't exactly the bits-on-disk either.) > > jsonb_send() sends a version number byte, currently 1. So if we invent a new version we would send 2 and teach jsonb_recv to be able to handle both. This was kinda anticipated. I agree that just sending a blob of the internal format isn't a great idea. cheers andrew -- Andrew Dunstan https://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
В списке pgsql-hackers по дате отправления: