1,Mongodb 属于NoSql中的文档型数据库,支持JSON存储;Mysql从5.7开始,也支持JSON存储,两者有什么区别?
参考文章:
1.1 MySQL 特点:
– 属于关系型数据库;
擅长处理一列对应一个值;(For relational databases: use one column per value. Putting a JSON blob in a column makes it virtually impossible to query (and painfully slow when you actually find a query that works).)
创建的索引,会充分利用该列的数据类型,适用于规整的数据结构。(Relational databases take advantage of data types when indexing, and are intended to be implemented with a normalized structure.)
存储JSON的场景,是该JSON数据只是查询,或者展示使用。(If you're adding true metadata, or if your JSON is describing information that does not need to be queried and is only used for display, it may be overkill to create a separate column for all of the data points.)
如果不采用JSON存储,需要三张table表示关联关系
如下代码,需要扫描全表(table-scan)
The claim about "efficient access" is misleading. It means that after the query examines a row with a JSON document, it can extract a field without having to parse the text of the JSON syntax.But it still takes a table-scan to search for rows. In other words, the query must examine every row.
SELECT * FROM t1
WHERE JSON_EXTRACT(data,"$.series") IN ...
1.2 Mongodb 特点:
结构灵活存储(Schemaless);