环境
条目 |
说明 |
机型 |
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 |
Postgres |
版本:9.6.9 docker image: postgres:9.6.9-alpine container 内存限制:128M 其他为默认配置 |
数据库设计
列 |
类型 |
备注 |
size |
int |
|
weight |
int |
|
json |
json |
{“size”:1, “weight”: 1} |
jsonb |
jsonb |
{“size”:1, “weight”: 1} |
- 行数:10万行数据
- json query 示例:select sum((jsonb->>’size’)::int) as s, sum((jsonb->>’weight’)::int)as w, sum((jsonb->>’not’)::int) as n from json_bench;
评测内容
聚合
聚合(sum)列 |
耗时(ms) |
size |
44 |
json->size |
147 |
jsonb->size |
67 |
size, weight |
43 |
json->size, json->weight |
237 |
jsonb->size, jsonb->weight |
144 |
排序
查询列 |
排序列 |
耗时(ms) |
size, weight |
size |
54 |
json->size, json->weight |
json->size |
242 |
jsonb->size, jsonb->weight |
jsonb->size |
138 |
参考
功能:https://www.postgresql.org/docs/9.6/datatype-json.html
操作:https://www.postgresql.org/docs/9.6/functions-json.html