This recursive CTE on a self-referencing employee table never terminates in some data. What is the most likely structural cause?
WITH RECURSIVE chain AS (
SELECT id, manager_id FROM emp WHERE id = 1
UNION ALL
SELECT e.id, e.manager_id
FROM emp e JOIN chain c ON e.manager_id = c.id
)
SELECT * FROM chain;