58 points · by johnchristopher · 11y ago · 49 comments
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.
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?
[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.