Tommi Prami wrote 14.10.2025 8:46:
> With foreign keys and all, you could basically build a tree of tables that can
> be processed independently and in parallel.
It is actually trivial:
1. Get list of tables and list of foreign keys (except self-references).
2. Add tables that has no references into the sorted list in any order.
3. For each table from the rest, if all referenced tables are already in list,
add the table into the list.
4. Repeat 3) until no tables left (success) or no tables was added in current
iteration (failure).
5. In the case of failure the rest of tables forms loop so this database cannot
be parallelised automatically and you must solve it somehow depending of your
task. For example, by adding them into the sorted list staring from the table
with smallest number of "unresolved" reference.
The resulting list can be processed in parallel up to tables referencing to
still unprocessed tables.
--
WBR, SD.