I am attempting to refactor some code from another developer. Attached is the Original Execution Plan I am tackling. The SQL using#TemDB tables which makes sense as they reference the table 5x so a CTE would not be efficient.
They are doing a lot of select distinct, UNION - EXCEPTS, MERGE JOINS. So expensive sorts in the TempDB. I am simplifying their code to eliminate most of the force sprt statements. My question is what is the fact the worst part of the Batch is 0% with like 9k estimated cost I think I know but cannot find a good article or Video to confirm what I think this is saying to me. Any links that would relate to my question, would be grateful