Regarding the concurrent creation, I’ve added concurrent_forall/2,3 to library(threads), so we can create the DB using the code below. That does more or less the same as my previous post. The implementation of concurrent_forall/3 is way more complicated to deal with failure and exceptions in the worker pool to abandon the computation and fail/throw. It was a bit of a challenge
fill(N,M) :-
concurrent_forall(between(1, N, I),
( numlist(0, I, L),
random_permutation(L, K),
assert(t(I, L, K))
),
[threads(M)]).