Postgresql Postgres递归json限制
参考 在末尾添加limit确实限制了返回,但似乎在每个记录的内部都进行了检查 有可能限制在一个带接头的内部吗 此查询在大型数据集上非常困难。Postgresql Postgres递归json限制,postgresql,recursive-query,jsonb,Postgresql,Recursive Query,Jsonb,参考 在末尾添加limit确实限制了返回,但似乎在每个记录的内部都进行了检查 有可能限制在一个带接头的内部吗 此查询在大型数据集上非常困难。 但是,我确实看到我可以在平面选择中限制时间戳范围。如果要限制行数,则应在初始查询中添加order by和limit,例如: with recursive flat (id, timestamp, path, value) as ( (select id, timestamp, key, value from trending_snapsh
但是,我确实看到我可以在平面选择中限制时间戳范围。如果要限制行数,则应在初始查询中添加
order by
和limit
,例如:
with recursive flat (id, timestamp, path, value) as (
(select id, timestamp, key, value
from trending_snapshot,
jsonb_each(snapshot)
order by id
limit 12)
union all
select f.id, f.timestamp, j.key, j.value
from flat f,
jsonb_each(f.value) j
where jsonb_typeof(f.value) = 'object' )
select timestamp, path, (value->>'value')::float AS value
from flat
where path like any(array['%Run01TubingPressure'])
或者额外的
where
子句(在初始查询中)根据条件筛选行。。最终,我们正在努力提高性能。到目前为止,只需执行“select*from trending_snapshot limit X;”,然后在python脚本中解析json,这可能是一个正确的方向,因为递归不是RDBMS(在性能方面)的优点。哦,好的。非常感谢。
with recursive flat (id, timestamp, path, value) as (
(select id, timestamp, key, value
from trending_snapshot,
jsonb_each(snapshot)
order by id
limit 12)
union all
select f.id, f.timestamp, j.key, j.value
from flat f,
jsonb_each(f.value) j
where jsonb_typeof(f.value) = 'object' )
select timestamp, path, (value->>'value')::float AS value
from flat
where path like any(array['%Run01TubingPressure'])