【问题标题】:Postgres Cluster (citus): Range Query on nested jsonb columnPostgres Cluster (citus):嵌套 jsonb 列上的范围查询
【发布时间】:2016-10-15 08:04:55
【问题描述】:

我正在使用 citus 5.2 配置为集群的 postgres 9.5.4

已使用以下命令对表进行了分片。

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
    }   ] 
}

下面的查询抛出错误,因为它在非分片表上执行。

select count(1) from mytest,jsonb_array_elements(data->'l') where (value->>'e')::bigint>7000;

错误:无法对此查询执行分布式规划

DETAIL:目前不支持复杂的表表达式

【问题讨论】:

    标签: json postgresql citus


    【解决方案1】:

    jsonb_array_elements(data->'l') 导致创建 CTE,导致此查询被拒绝,您能否重新编写查询以避免连接?

    【讨论】:

      猜你喜欢
      • 2017-02-23
      • 2017-01-28
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      • 2021-02-18
      • 2023-04-03
      • 2019-03-14
      • 1970-01-01
      相关资源
      最近更新 更多