Postgres 9.3 feature highlight: JSON operators
michael.otacoo.com
michael.otacoo.com
This is an absolutely beautiful commit message
Many of the presentations on using plv8 to access JSON in Postgres 9.2 (e.g., https://wiki.postgresql.org/images/b/b4/Pg-as-nosql-pgday-fo... ) show the use of functional indexes, but they create a plv8 function marked as immutable.
I imagine you could create a wrapper function marked immutable that calls the provided json accessor functions, but I'm not really clear on the implications of doing so.
So now it is indeed possible!
In the specific case, it removes the data transformation code required to convert the clojure data structures I have to sql, json, or xml that postgresql understands.
You can embed a JVM in PostgreSQL and write the functions yourself (or use PL/Scheme I suppose), but I would be basically amazed if anyone decides to do it for you.
JSON gets the nod because it's understood by billions of systems. Other formats are going to struggle.
I asked because I wanted to know if there was a particular reason for your wishes -- which is, as I said, quite parochial compared to the reach of JSON -- over other potential priorities. If asking questions is "trolling", I'll be over here with 4chan and Socrates.
the stuff about EDN being natively supported by clojure is a red herring and irrelevant.
RFC6901: JSON Pointer
RFC6902: JSON Patch
-- are there indexes that assisted queries against JSON datastructures stored in JSON type fields?
I only say this because I've been there, with SQL Server's XML processing stuff, then spent nearly 2 years getting rid of it.
For me, the native JSON support is a very handy tool to have in the toolbelt for parts of our application that have a very loose schema.
Logic suggests that you should keep as much processing functionality outside something which can't be scaled cheaply or easily and push it to cheaper front end servers.
On this basis, anything which implies more work than collecting and shifting the data over the wire shouldn't really be in the database. Parsing / processing JSON is one of those things that's going to eat CPU/memory.
Fundamentally there's nothing wrong with storing JSON inside the database and processing it externally, but processing it inside the database is a big risk.
I've seen the same thing over the years with XML in the database and more recently people adding CLR code to SQL Server stored procedures.
Sure, doing this hampers normalization and single server speed, but if the queries are parallelizable with shards et al, what would hamper scalability?