Re: jsonb and nested hstore - Mailing list pgsql-hackers

From Josh Berkus
Subject Re: jsonb and nested hstore
Date
Msg-id 530E2CDA.5020509@agliodbs.com
Whole thread Raw
In response to jsonb and nested hstore  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: jsonb and nested hstore  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-hackers
On 02/26/2014 09:57 AM, Merlin Moncure wrote:
> On Wed, Feb 26, 2014 at 11:41 AM, Josh Berkus <josh@agliodbs.com> wrote:
>> On 02/26/2014 07:02 AM, Merlin Moncure wrote:
>>> On Tue, Feb 25, 2014 at 3:57 PM, Hannu Krosing <hannu@2ndquadrant.com> wrote:
>>>> It is not in any specs, but nevertheless all major imlementations do it and
>>>> some code depends on it.
>>>> IIRC, this behaviour is currently also met only by json and not by jsonb.
>>>
>>> Yes: This was the agreement that was struck and is the main reason why
>>> there are two json types, not one.  JSON does not guarantee field
>>> ordering as I read the spec and for the binary form ordering is not
>>> maintained as a concession to using the hstore implementation.
>>
>> Actually, that's not true; neither Mongo/BSON nor CouchDB preserve field
>> ordering.  So users who are familiar with JSONish data *storage* should
>> be aware that field ordering is not preserved.
> 
> right (although I'm not sure what wasn't true there).  I think the

Sorry, I was referring to Hannu's statement that "all major
implementations preserve order", which simply isn't true.

> status quo is fine; If you have to have the document precisely
> preserved for whatever reason you can do that -- you just have to be
> prepared to give up some things.  As noted in the other thread
> serialization is more interesting but that also works fine.  The
> breakdown in terms of usage between json/jsonb to me is very clear
> (json will handle serialization/deserializaton heavy patterns and a
> few edge cases for storage).   The split between json and jsonb in
> hindsight made a lot of sense.
> 
> What is not going to be so clear for users (particularly without good
> supporting documentation) is how things break down in terms of usage
> between hstore and jsonb.

Realistically?  Once we get done with mapping the indexes and operators,
users who are used to Hstore1 use Hstore2, and everyone else uses jsonb.jsonb is nothing other than a standardized
syntaxinterface to hstore2,
 
and most users will choose the syntax similar to what they already know
over learning new stuff.

A real, full comparison chart would include text, json, jsonb and
hstore, I guess.  Although I'm wondering if that's way too complex for
the main docs.  Seems like more of a wiki item.

-- 
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com



pgsql-hackers by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: jsonb and nested hstore
Next
From: salah jubeh
Date:
Subject: Function sugnature with default parameter