Files
speckle-server/test-queries/closure-fullcount.sql
T
Dimitrie Stefanescu 85cc525663 feat(queries): figuring out the perfect querie for getting objects
quite a few things are being considered, perf. wise: pagination, ordering, querying, depth.
2020-05-04 16:25:37 +01:00

18 lines
462 B
SQL

with objs as (
SELECT
-- child as id,
id,
serial_id, -- just for reference
"data"
FROM object_children_closure
JOIN objects ON objects.id = child
WHERE parent = '7919a52c017be262ee0daf1844c376d7'
AND "minDepth" < 1000
-- AND (objects."data" -> 'sortValueA')::numeric <= 700
-- AND (objects."data" -> 'sortValueA')::numeric > 100
ORDER BY id
)
SELECT * FROM objs
RIGHT JOIN (SELECT count(*) FROM objs ) c(total_count) ON TRUE
OFFSET 100
LIMIT 200