I'm developing a system which processes a large number of stored procedures. As I run the system, I comment out the stored procedures that work and move on - that way I'm not waiting ages to see if my latest additions work or not. For example, part A, part B, part C
all work, so when I come to develop part D, I comment out A, B & C, allowing SQL to go straight to part D.
What I've found is that if I run parts A, B & C prior to running part D, then D runs in (let's say) 5 mins. But when I comment out parts A, B & C, and go straight to part D, then it takes (let's say) 5 hours to run.
Parts A, B & C would have already created all the tables, indexes, etc, necessary for part D to execute, but why should it take so much longer when processed on it's own?
Does the optimizer need parts A, B & C to warm up?