Re:Performant database tree traversal with Rails
by e12e on Wednesday July 12, 2023 @06:38PM
(#36702627)
I'm not sure I even understand the sample SQL, given:
> Each snapshot can have one or two parents. When merging branches, we perform a breadth-first search on the history of each change until we find the common ancestor between both branches. This is the merge base.
And the SQL:
select * from schema_snapshots where id = 20
(...)
schema_snapshots where id = 24
// *thousands more queries*
Why select star here? Surely they mean:
SELECT left_parent_id as parent_id FROM schema_snapshots )
UNION
(SELECT right_parent_id as parent_id FROM schema_snapshots)
WHERE id in (1,2,3...)
> Each snapshot can have one or two parents. When merging branches, we perform a breadth-first search on the history of each change until we find the common ancestor between both branches. This is the merge base.
And the SQL:
Why select star here? Surely they mean: or something?