JSON Labs Release: Native JSON Data Type and Binary Format
mysqlserverteam.com
mysqlserverteam.com
JSON is the object literal format for Javascript, likely the single most widely deployed and used programming language in the world. Until paradigm shifts obsolete the web browser, JSON will be ubiquitous.
We'll see. I definitely expect JSON to remain popular for many years at the least.
What intrigues me is why is it so. There is a great article in one of the Programming Pearls books (so, published earlier), that goes over how providing provenance in a data format is highly useful. Yet, by and large, you can not do this in JSON, because comments are disallowed.
Go ahead and read this article from MS SQL server from 2004, about introducing similar features for XML (binary storage, functional indexes) inside the database.
https://msdn.microsoft.com/en-us/magazine/cc188738.aspx
In 10 years, the relational model didn't budge. There are loads of good reasons for why you'd want to decompose data into native DB types, with a strongly-typed schema.
But JavaScript has the JSON object offering a high-quality, high-performance parser (JSON.parse) and serialiser (JSON.stringify).
In what sense?
NoSQL databases are adopting standard SQL interfaces and becoming more uniform.
SQL databases are adopting their own JSON interfaces and becoming more proprietary.
SQL databases are implementing features their users are requesting.
https://mariadb.com/kb/en/mariadb/connect-json-table-type/
e.g:
SQL > CREATE TABLE junk.j1 (a int default null)
ENGINE=CONNECT DEFAULT CHARSET=utf8
table_type=JSON
File_name='j1.json';
SQL > insert into junk.j1 (values) (1);
$ ls $(mysql -NBe "select @@datadir")/junk
db.opt j1.frm j1.json
$ cat $(mysql -NBe "select @@datadir")/junk/j1.json
[
{
"a": 1
}
]
I use this for generating config files, and getting data into pydata tools; no need for a database driver, which is interesting. You can... [create] indexes on values within the JSON columns
Ability to index changes everything. 8.14.4. jsonb Indexing
...
However, the [GIN] index could not be used for queries like the following:
-- Find documents in which the key "tags" contains key or array element "qui"
SELECT jdoc->'guid', jdoc->'name' FROM api WHERE jdoc -> 'tags' ? 'qui';
[1]: http://www.postgresql.org/docs/9.4/static/datatype-json.htmlThis design allows MySQL to implement both without the backwards compatibility concern.
https://prestodb.io/docs/current/functions/json.html
https://cloud.google.com/bigquery/query-reference#jsonfuncti...
When postgres added JSON operations it brought the sanity and robustness of its database engine to the wild west of document stores.
What's MySQL bringing?
PostgreSQL doesn't preserve key ordering and strips multiple key/values pairs. I know some systems we have insist on JSON documents having a set order sequence. Also there are often legal reasons why you need the raw, unmodified data preserved.
If you business has legal implications on your database format, then why would you trust a NoSQL implementation?
For example - financial transactions: https://twitter.com/seldo/status/413429913715085312
I've had to deal with these kinds of systems before, and they are a giant pain in the ass, usually doing some kind of string parsing on the JSON blob or other asinine fake-parsing. While I'd normally agree with you in premise, you're asking for an edge case that doesn't conform to the spec. Additionally, the easiest way to keep the raw, unmodified data preserved, yet still be able to operate and potentially change that data, is to duplicate the data. As soon as that data hits your system, throw it in an immutable TEXT column that your warehouse can suck up and store indefinitely, then normalize and mutate the hell out of it in your operational database, all the while keeping an 'original_data' key back to the raw text. Problem solved.
[0] https://mariadb.com/kb/en/mariadb/dynamic-columns/
[1] http://www.slideshare.net/blueskarlsson/using-json-with-mari...
[2] https://mariadb.com/kb/en/mariadb/virtual-computed-columns/
I am speechless.
The relational model has no performance model. The existence of ever more complicated query optimizers proves this. This is fundamental engineering issue, and NoSQL and JSON in MySQL are engineering hacks that address this issue for specific problems.
It's also a big usability issue. Even if you can tune your queries, indices, and schemas to remove a given performance bottleneck; it could be beyond the skills of users. NoSQL and JSON are indeed simpler.
So it would be nice to come up with a better model instead of one-off hacks, but it's hard. I think it would be cool if you could exhaustively enumerate the queries an application makes, and then the database would somehow generate the schema and indices for you, and also give the time complexity bounds for the queries. But there is kind of a chicken and egg problem there, because the queries depend on the schema.
All of these operations are already supported for XML in most databases that were around 5-10 years ago, and the same pitfalls with keeping all your data in XML inside the database also apply to JSON.