Mark/Bret,
Bret: Your assumption is correct. The second and subsequent runs execute extremely quickly because the plan is in cache.
Also, the stored procedure has a number of complex joins along with temporary table usage resulting in long compilation times and deferred compilation scenarios.
Mark & Bret: As per your suggestions, I created 2 ISQL sessions; one to run Mark's query and the other to run Bret's stacktrace every 10 seconds on the 1st SPID. I repeated this twice in quick succession. The first one took 24 minutes to run. The second one took under 1 second!
The ASE is running a 'threaded kernel' model. Is there something I can configure at the server level to alter/control this behavior?
Thanks,
Anil
PS: The outputs are attached to this post.