Postgres hierarchical (jsonb) CTE unnecessarily slow
问题 I have a JsonB column in my table which holds hierarchical information. MyTable (id uuid, indexes jsonb, content bytea) Now if I create a CTE say WITH RECURSIVE hierarchy(pid, id, content) AS ( --load first parents SELECT t.indexes ->> 'parentId' as pId, t.id, t.content FROM MyTable c JOIN MyTable t ON t.indexes ->> 'Id' = c.indexes ->> 'parentId' WHERE c.Id = ANY('{..Some UUIDS}') UNION SELECT t.indexes ->> 'parentId' as pId, t.id, t.content FROM hierarchy h, MyTable t WHERE t.indexes ->>