1
我使用配置爲羣集postgres的9.5.4使用西特斯5.2Postgres的集羣(西特斯):範圍查詢對嵌套jsonb柱
使用下面的命令表已分片。
SELECT master_create_distributed_table('mytest', 'id', 'hash');
SELECT master_create_worker_shards('mytest', 16, 1);
從下面存儲在jsonb列樣品JSON數據,我想搜索記錄匹配的
o['mid'] > 7000
這是一個用戶的記錄的樣本。將有數百萬這樣的用戶。
{ "uid": 14105529, "o": [
{
"mid": 6551,
"ac": 1913,
"ip": "144.36.233.44",
"adw": 5,
"at": 133000,
"ad": 151015,
"aid": 0
},
{
"mid": 7552,
"ac": 1913,
"ip": "144.36.233.44",
"adw": 5,
"at": 133000,
"ad": 151015,
"aid": 0
},
{
"mid": 7553,
"ac": 1913,
"ip": "144.36.233.44",
"adw": 5,
"at": 133000,
"ad": 151015,
"aid": 0
} ]
}
下面的查詢會引發錯誤,因爲它在un-sharded表上執行。
select count(1) from mytest,jsonb_array_elements(data->'l') where (value->>'e')::bigint>7000;
ERROR: cannot perform distributed planning on this query
DETAIL: Complex table expressions are currently unsupported