Hi,
I'm just on the tail-end of fixing an issue at my place of work where a sproc went from taking 5-10 minutes to run to failing to return anything within an hour. The stored procedure in question is essentially a chain of CTEs with the first two returning the required dataset (first CTE is about 200k rows and the second narrows it down to about 10k), with 6 or so further CTEs performing calculations on this data to return certain business KPIs. It looks a bit like this pseudo-code:
WITH CTE1 AS (
SELECT * FROM BusinessData WHERE Date BETWEEN @ParameterDate1 AND @ParameterDate2 AND Condition1 = 1)
, CTE2 AS (SELECT * FROM CTE1 JOIN SecondaryBusinessData ON X = X WHERE CTE2.Co

![Export settings adding additional letterboxing to video [See comments]](https://i.redd.it/662u0pcxff9c1.png)