4 ms·
Maybe you could use the technique of maintaining a separate adjacency list column and materializing the ordering list. It would be a simplified version of what
by gregwebs 4y ago
Maybe you could use the technique of maintaining a separate adjacency list column and materializing the ordering list. It would be a simplified version of what is done for hierarchy to materialize a nested set: https://www.sqlservercentral.com/articles/hierarchies-on-steroids-1-convert-an-adjacency-list-to-nested-sets https://www.sqlservercentral.com/articles/hierarchies-on-ste...
A DB type could be nice to hide away the adjacency list.
The other suggestion here to use fractional numbers is similar to materialized path (ltree data type in Postgres) and has been formalized to apply to hierarchies with Farey Fractions: https://sigmodrecord.org/publications/sigmodRecord/0506/p47-article-tropashko.pdf https://sigmodrecord.org/publications/sigmodRecord/0506/p47-...
- danielheath 4y agoIf I were happy to rewrite the queries, I could use something like (forgetting the exact incantation)`select row_number(), rest_of_table as position partition by playlist_id order by position` to get the position column.