Re: PATCH: Add hstore_to_json() - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: PATCH: Add hstore_to_json()
Date
Msg-id 4B2C18DA.50407@dunslane.net
Whole thread Raw
In response to Re: PATCH: Add hstore_to_json()  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: PATCH: Add hstore_to_json()  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers

Robert Haas wrote:
> On Fri, Dec 18, 2009 at 3:00 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>   
>> Alvaro Herrera <alvherre@commandprompt.com> writes:
>>     
>>> Tom Lane escribió:
>>>       
>>>> Well, actually, now that you mention it: how much of a json type would
>>>> be duplicative of the xml stuff?  Would it be sufficient to provide
>>>> json <-> xml converters and let the latter type do all the heavy lifting?
>>>> (If so, this patch ought to be hstore_to_xml instead.)
>>>>         
>>> But then there's the matter of overhead: how much would be wasted by
>>> transforming to XML, and then parsing the XML back to transform to JSON?
>>>       
>> Well, that would presumably happen only when sending data to or from the
>> client.  It's not obvious that it would be much more expensive than the
>> syntax checking you'd have to do anyway.
>>
>> If there's some reason to think that operating on json data would be
>> much less expensive than operating on xml, there might be a case for
>> having two distinct sets of operations internally, but I haven't heard
>> anybody make that argument.
>>     
>
> One problem is that there is not a single well-defined mapping between
> these types.  I would say generally that XML and YAML both have more
> types of constructs than JSON.  The obvious ways of translating an
> arbitrary XML document to JSON are likely not to be what people want
> in particular cases.
>   

Right. XML semantics are richer, as I pointed out when we were 
discussing the various EXPLAIN formats.


> I think the performance argument is compelling, too, but we can't even
> try benchmarking it unless we can define what we're even talking
> about.
>
>
>   

Yes, there is indeed reason to think that JSON processing, especially 
parsing, will be more efficient, and I suspect we can provide ways of 
accessing the data that are lots faster than XPath. JSON is designed to 
be lightweight, XML is not.

Mind you, the XML processing is not too bad - I have been working much 
of the last few months on a large custom billing system which produces 
XML output to create paper/online invoices from, and the XML 
construction is one of the fastest parts of the whole system.

cheers

andrew


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Removing pg_migrator limitations
Next
From: Tom Lane
Date:
Subject: Re: Removing pg_migrator limitations