Re: Wanted: jsonb on-disk representation documentation

From: Peter Geoghegan <pg(at)heroku(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Wanted: jsonb on-disk representation documentation
Date: 2014-05-07 17:55:28
Message-ID: CAM3SWZTTN49ffScwm+UG+R2dQ14Acmm7P1oGivtC6Gn4GC8A0A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, May 7, 2014 at 4:40 AM, Andres Freund <andres(at)anarazel(dot)de> wrote:
> * Imo we need space in jsonb ondisk values to indicate a format
> version. We won't fully get this right.

That would be nice.

> * The jentry representation should be changed so it's possible to get the type
> of a entry without checking individual types. That'll make code like
> findJsonbValueFromSuperHeader() (well, whatever you've renamed it to)
> much easier to read. Preferrably so it an have the same values (after
> shifting/masking) ask the JBE variants. And it needs space for futher
> types (or representations thereof).

I don't know what you mean. Every place that macros like
JBE_ISNUMERIC() are used subsequently involves access to (say) numeric
union fields. At best, you could have those functions check that the
types match, and then handle each case in a switch that only looked at
(say) the "candidate", but that doesn't really save much at all. It
wouldn't take much to have the macros give enum constant values back
as you suggest, though.

> * I wonder if the hash/object pair representation is wise and if it
> shouldn't be keys combined with offsets first, and then the
> values. That will make access much faster. And that's what jsonb
> essentially is about.

I like that the physical layout reflects the layout of the original
JSON document. Besides, I don't think this is obviously the case. Are
you sure that it won't be more useful to make children as close to
their parents as possible? Particularly given idiomatic usage. Jsonb,
in point of fact, *is* fast.

> * I think both arrays and hashes should grow individual structs. With
> space for additional flags.

Why?

--
Peter Geoghegan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2014-05-07 18:04:48 Re: proposal: Set effective_cache_size to greater of .conf value, shared_buffers
Previous Message Stephen Frost 2014-05-07 17:39:17 Re: [v9.5] Custom Plan API