环境
条目 |
说明 |
机型 |
MacBook Pro (13-inch, 2017, Two Thunderbolt 3 ports) |
OS |
macOS Catalina 10.15.1 |
CPU |
2.3 GHz 双核Intel Core i5 |
内存 |
8 GB 2133 MHz LPDDR3 |
磁盘 |
Macintosh HD |
MySQL |
mysql Ver 8.0.17 docker image: mysql container 内存限制:256M 其他为默认配置 |
数据库设计
行数:100万行数据
列 |
类型 |
备注 |
size |
int |
|
weight |
int |
|
json |
json |
{“size”:1, “weight”: 1} |
评测结果
插入
耗时40815ms
提取元素
select json->"$.size", json->"$.weight" from bench_json limit 1000000;
提取列 |
耗时(ms) |
size |
917 |
size, weight |
1376 |
json.size |
1283 |
json.size, json.weight |
2123 |
遍历
select * from bench_json where json->"$.size" = 99999;
scan列 |
耗时(ms) |
size |
572 |
json->size |
815 |
聚合
select sum(json->"$.size"), sum(json->"$.weight") from bench_json;
聚合(sum)列 |
耗时(ms) |
size |
480 |
json->size |
667 |
size, weight |
557 |
json->size, json->weight |
886 |
排序
select * from bench_json order by json->"$.size" desc
排序列 |
耗时(ms) |
size |
705 |
json->size |
1200 |
参考
https://dev.mysql.com/doc/refman/5.7/en/json.html