Hacker News new | ask | show | jobs
by tsewlliw 3012 days ago
This is probably decently efficient if you use recursive CTE's to traverse it, and use keyset pagination rather than limit/offset.

    with recursive cte (udo_id, prv, nxt, label) as (
        select * 
        from udo
        where udo_id = :first_item_id
        union all 
        select u.*
        from udo u
        join cte
        on u.prv = cte.udo_id
    ) select * from cte limit 100