@prologic@twtxt.net Yeah, relational databases are definitely not the perfect fit for trees, but I want to give it a shot anyway. :-)
Using EXPLAIN QUERY PLAN
I was able to create two indices, to avoid some table scans:
CREATE INDEX parent ON messages (hash, subject);
CREATE INDEX subject_created_at ON messages (subject, created_at);
Also, since strings are sortable, instead of str_col <> ''
I now use str_col > ''
to allow the use of an index.
But somehow, my output seems to be broken at the end for some reason, I just noticed. :-? Hmm.
The read status still gives me headache. I think I either have to filter in the application or create more meta data structures in the database.
I’m wondering if anyone here already used certain storages for tree data.