Is PostgreSQL's Ltree module a good fit for threaded comments?

后端 未结 3 1900
时光说笑
时光说笑 2021-01-31 06:47

I\'m considering using PostgreSQL\'s Ltree module in my application to help with threaded comments. I\'ve been eying it for a while to use for threaded comments. I figure it w

3条回答
  •  既然无缘
    2021-01-31 06:54

    I recommend anyone implementing hierarchical relationships in SQL read Joe Celko's Trees and Hierarchies in SQL for Smarties.

    Traversing arbitrary depth parent child links can be very inefficient when using just a parent_id. The book describes techniques that make this access fast.

    One strategy (which I happen to use) can also be found for free in this series of articles:

    • Part 1 (look for the section "Trees in SQL") (Wayback link)
    • Part 2 (Wayback link)
    • Part 3 (Wayback link)
    • Part 4 (Wayback link)

提交回复
热议问题