I have a very complex query involving 6 tables, needing to find max values, and counting items, as based on multiple columns in multiple other tables and then combining them under one column.
I've mostly got everything worked out, but basically had to use the WITH clause so many times I'm a bit concerned about runtime speed. I've probably used it 8+ times. Does anybody know how SQL actually calculates these on the backend? is it actually building a whole table, or is it basically just another wording for sub queries and joins? How many with clauses is too many? The counting and combining is why I have so many fwiw.
I used the WITH clause and would like a way to gage this solutions runtime speed compared to other options.