I need help evaluating the actual execution plan of an SQL Server View:
/?id=zAFOrTkUxr
Context
The above View is being called by Azure Data Factory to populate a table in our Azure Analysis Server DB. The problem is it's using an inordinate amount of system memory on the AAS server to do so and sometimes causing us to exceed our S1 tier memory allocation of 25GBs for the AAS instance. When the AAS server is idle it's using around 7.4GBs of memory but once it starts trying to populate the table from this View on the SQL Server instance then it jumps up to around 25GBs.
The resultset from the View is roughly 6.2M records and it takes approximately 7m 30s for it to execute. We do a full truncate and reload of the table every day.
I did not create this View or the process that loads it; this all pre-dates me but I am the one left with trying to get this under control.
What I've tried
I am not a DBA by trade, but I know that Views can be very costly in terms of performance. What I did as a test was took the results from the View and inserted them into a physical table on the SQL Server. The only thing I did was create a compound PK on the table using the [work_day_bookings_ver_key] and [Relationship Type] columns. I can run a SELECT on all 6.2M records from this table in approximately 42s. When I load the corresponding table on the AAS instance from this new table it only consumes approximately 400MBs of memory. This is obviously a HUGE uplift in performance overall. The downside of course is now we have an additional physical table on the SQL Server instance but it's only taking up approximately 700MBs of space which I feel is a more than worthy tradeoff.
Now we can potentially implement what I described above as the final solution, but this does go outside of our established processes of calling Views on the SQL Server instance to populate the tables in the AAS instance. My superiors aren't opposed to doing this but would like to know if we've exhausted all options of improving the performance of the View and well, I don't really know hence why I'm here.
Questions
Can someone please help me analyze the execution plan? I don't fully understand where to begin in determining where the bottlenecks are and where I could get the most "bang for the buck"?
Bonus question: If anyone understands AAS, is there a way to tell how much memory that a query will consume? I don't fully understand why this View, regardless of how poorly optimized it is, would cause so much memory to be consumed on the AAS server side? Like, I could understand if it performs poorly on the SQL server side but then shouldn't it just hand over the data to AAS after it gets the results back? Instead, it seems like it's really being executed on the AAS server (and maybe/probably it is which is the problem!).