Re: JSON Patch for PostgreSQL - BSON Support?

From: Joseph Adams <joeyadams3(dot)14159(at)gmail(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Charles Pritchard <chuck(at)jumis(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: JSON Patch for PostgreSQL - BSON Support?
Date: 2010-08-16 17:17:11
Message-ID: AANLkTik0VQdKFUTYdPt=xZ9ntssq9Kv_JPbWQa4LYq=t@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Aug 15, 2010 at 11:47 PM, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
>
> If BSON is simply in effect an efficient encoding of JSON, then it's not
> clear to me that we would want another type at all. Rather, we might want to
> consider storing the data in this supposedly more efficient format, and
> maybe also some conversion routines.

An issue is that the current JSON data type implementation preserves
the original text (meaning if you say '[1,2,"\u0020" ]'::JSON, it
will yield '[1,2,"\u0020" ]' rather than '[1,2," "]' . I haven't
researched BSON much at all, but I seriously doubt that part of its
spec includes handling external JSON encoding details like whitespace
and superfluous escapes.

Even though I spent a long time implementing it, the original text
preservation feature should be dropped, in my opinion. Users tend to
care more about the data inside of a JSON value rather than how it's
encoded, and replacement of values can have funky consequences on
indentation when working with indented JSON text (similar to how
pasting in a text editor puts pasted content at the wrong indent
level).

By dropping original text preservation, in the future (or now), JSON
could be encoded in BSON (or a more efficient format) in the database
rather than in JSON-encoded text.

Also, an idea would be to make json_send and json_recv (binary JSON
send/receive) use BSON rather than JSON-encoded text, as
sending/receiving JSON-encoded text is exactly what text send/receive
do.

Joey Adams

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dean Rasheed 2010-08-16 17:23:14 Re: Proposal / proof of concept: Triggers on VIEWs
Previous Message Magnus Hagander 2010-08-16 16:51:45 Re: Committers info for the git migration - URGENT!