matthiask / 406-comments

Test repository for using https://utteranc.es/ for https://406.ch/
https://406.ch/
0 stars 0 forks source link

writing/django-tree-queries/ #2

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

django-tree-queries - Matthias Kestenholz

https://406.ch/writing/django-tree-queries/

guettli commented 3 years ago

Thank you!

Mogost commented 3 years ago

Could you please describe in more details why ltree does not seem to be a good solution?

matthiask commented 3 years ago

@Mogost There are a few downsides which make me doubt whether ltree would be better* than recursive CTEs:

These two points mean that you need a bit of code to manage the tree and keep all those values in sync. Exactly the thing which made me leave django-mptt behind because of recurring problems with broken trees.

You should only denormalize data when you have to, e.g. because your app would perform really badly without denormalization. I think adjacency lists and recursive CTEs hit the sweet spot for a lot of use cases – no denormalization and (better than) adequate performance.

Finally, ltree is (obviously) PostgreSQL-only, and while that wouldn't be a big problem for me it's nice that recursive CTEs work well on a number of databases. (django-tree-queries' initial releases only supported PostgreSQL).

* Better for my use case.

Mogost commented 3 years ago

@matthiask Thank you very much for your detailed explanation.

raratiru commented 2 years ago

OK, I have just set an alarm:

Every time I struggle whether to use or not a multi-thousand line application I will visit your profile, searching for a similar solution "in the hundreds".