LWN.net Logo

Why json

Why json

Posted Sep 12, 2012 9:17 UTC (Wed) by ringerc (subscriber, #3071)
In reply to: Why json by aristedes
Parent article: PostgreSQL 9.2 released

Right now it's #3 with validation, plus some functions to turn result sets or arrays into structured JSON for easy consumption in applications. That's the main benefit at this point.

However, future versions are extremely likely to add enhancements like:

  • Indexing, like hstore currently has
  • Operators or functions to merge json objects, extract values, get key lists, etc like the hstore and xml support have
  • More features for constructing and consuming JSON in the DB

Because Pg is so extensible, much of that is likely to be available as backports into 9.2.


(Log in to post comments)

Why json

Posted Sep 12, 2012 9:32 UTC (Wed) by andresfreund (subscriber, #69562) [Link]

> Indexing, like hstore currently has
Its easier for hstore because hstore isn't nested and not individually typed (everything is a string).
An efficient index over arbitrary nesting and several types isn't exactly easy and I am not that sure that will come that soon. An opclass for not-nested json objects or such would be relatively easy though.

Why json

Posted Sep 12, 2012 10:29 UTC (Wed) by yodermk (subscriber, #3803) [Link]

MongoDB has something very much like that.

Why json

Posted Sep 12, 2012 10:42 UTC (Wed) by ringerc (subscriber, #3071) [Link]

Once there's a json lookup operator (say implementing the [] operator for json to get the value of a key, or a path lookup function kind of like xpath provides for xml) then a functional index might be reasonably practical, at least if the result is a scalar.

Right now the lack of the concept of a "scalar json value" (due to an IMO over-eager interpretation of the JSON "spec") is frustrating all sorts of things, including proper json constructor functions.

More general indexing might be done through GiST, but I imagine it'd be a pretty complicated job involving extracting paths-to-values.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds