在jsonb数组对象和索引中查询jsonb数组对象

问题描述

select
        picks ->> 'pid' as playerid,e.id,e.sportid,e.leagueid,e.islive,e.status,e.locationid,e.participants,em.bets
From
    sfbr.eventmarket em
        join sfbr.events e on em.eventid = e.id,jsonb_array_elements(em.bets) b,jsonb_array_elements((b->> 'b')::jsonb) picks
where (picks ->> 'pid') is not null
  and (picks ->> 'ec') is null
  and e.startdatetime > '2019-09-04 07:29:00.690834' and (picks ->> 'pid') in
                        ('1880686','1796512','1838464','851658','66675')
order by e.startdatetime desc;

嗨,这个查询要花上2到3分钟的时间,我该怎么写,这样我就不必两次做jsonb_array_elements了! 有什么办法可以索引数组内部数组中的“ pid”字段?

预先感谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)