Re: patch: Add JSON datatype to PostgreSQL (GSoC, WIP)

From: Terry Laurenzo <tj(at)laurenzo(dot)org>
To: Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Joseph Adams <joeyadams3(dot)14159(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: patch: Add JSON datatype to PostgreSQL (GSoC, WIP)
Date: 2010-10-20 06:58:34
Message-ID: AANLkTiknwbEFW-gFyndRfCXsYoyq8pRm=NKwHecQRyJw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Good points. In addition, any binary format needs to support object
property traversal without having to do a deep scan of all descendants.
BSON handles this with explicit lengths for document types (objects and
arrays) so that entire parts of the tree can be skipped during sibling
traversal.

It would also be nice to make sure that we store fully parsed strings.
There are lots of escape options that simply do not need to be preserved (c
escapes, unicode, octal, hex sequences) and hinder the ability to do direct
comparisons. BSON also makes a small extra effort to ensure that object
property names are encoded in a way that is easily comparable, as this will
be the most frequently compared items.

I'm still going to write up a proposed grammar that takes these items into
account - just ran out of time tonight.

Terry

On Wed, Oct 20, 2010 at 12:46 AM, Itagaki Takahiro <
itagaki(dot)takahiro(at)gmail(dot)com> wrote:

> On Wed, Oct 20, 2010 at 6:39 AM, Terry Laurenzo <tj(at)laurenzo(dot)org> wrote:
> > The answer may be to have both a jsontext and jsonbinary type as each
> will
> > be optimized for a different case.
>
> I want to choose one format for JSON rather than having two types.
> It should be more efficient than other format in many cases,
> and not so bad in other cases.
>
> I think the discussion was started with
> "BSON could represent was a subset of what JSON could represent".
> So, any binary format could be acceptable that have enough
> representational power compared with text format.
>
> For example, a sequence of <byte-length> <text> could reduce
> CPU cycles for reparsing and hold all of the input as-is except
> ignorable white-spaces. It is not a BSON, but is a binary format.
>
> Or, if we want to store numbers in binary form, I think the
> format will be numeric type in postgres. It has high precision,
> and we don't need any higher precision than it to compare two
> numbers eventually. Even if we use BSON format, we need to extend
> it to store all of numeric values, that precision is 10^1000.
>
> --
> Itagaki Takahiro
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dimitri Fontaine 2010-10-20 07:10:27 Re: Extensions, this time with a patch
Previous Message Itagaki Takahiro 2010-10-20 06:46:18 Re: patch: Add JSON datatype to PostgreSQL (GSoC, WIP)