Thanks for a detailed answer, I have been reworking my query which originally took 47 seconds using method 2 (one big sql script in a SP), this was passing say around 50,000 records to just display less than a 1000 aggregated rows. A long time I know.
Therefore I started again, breaking the large resultset into smaller resultset (using temp tables)
In all the reworked version took 4 temp tables and one query to join them at the end (in one SP), using method 1. The new time is now 7 seconds!!! for the query to run and display the CR.
I hope you can understand my joy here more than my wife did, when I tried to explain my day to her. :-)
Many thanks for the pointers
|