Composable SQL In JavaScript
Gal Schlezinger
222
The problem is that subqueries, especially deeply nested are hard to analyze for dbms query optimizer. From my experience with SQL Server sometimes it’s even better to move query result into #temp_table than use subquery.
Not sure DBA can help with it.