Thanks for replying. Yes, indeed that is the idea.
I tried using recursion and it covered the same 23 tables in the relation chains, but took a different relation path (because recursive goes off down the first relation chain exhaustively) than the above code. With the above code, the RELATE ONE command is different somewhere but I can’t fathom what mechanism 4D uses for deciding the path.
Results for the recursive version in my test case was 3 different records retrieved for 3 tables.
Results for the above version in my test case was 1 different record retrieved for 1 table.
Neither are the same as RELATE ONE, but the above code is a nearer match.
Also doing some time trials for 1000 records (all executed server side):-
RELATE ONE x 1000 iterations takes a total of 282 milliseconds
Above code x 1000 iterations takes approx 12000 milliseconds
I’ve just completed a change around to build a list of relations first into IP arrays which a new method can then use to iterate over. Speed is improved with that but still takes 2800 milliseconds for 1000 iterations.
Of course, I can’t use IP arrays with thread-safe either, but I figure I could refactor that to use one shared collection per table or something like that.
I’m really struggling here to try and work out an alternative solution.