Possible PARAMETER SNIFFING Scenario in SQL
When you undertake some performance improvement task, you think it is frustrating however at the same time you tend to learn more. So the other day we had to brain storm on one of the similar issues where the database stored procedure was returning data quickly as compared to the SSRS report (using same stored procedure) which seemed to be taking ages to run and display data. The initial investigation and their results were:- Finding out from excutionlog table where the issue is. Turned out that 'TimeDataRetrieval' was considerably high for previous runs of the report. This proved that the real cause was indeed the slow performance of the stored procedure. Checked to see whether it could be related to temp database. On connecting with the database admin this was ruled out. Checked to see the cpu utilization at the report server. Nothing significant was found. After doing all these steps, I thought that this issue might be related to the parameter sniffing. Paramet