A call to a stored procedure completes in 13 seconds when ran from within SQL Server Management Studio. A report whose data source uses the same stored procedure can take as long as 10 minutes to run. The same parameter values are used in both the direct call and the report. The execution log says almost all of that time is spent on data retrieval. How could that be What might be the cause

Data retrieval is much slower in RS than in management studio
icaughtacode
edwinzzz
csi_hugh
sorcer1
seco
Thanks for the questions.
Yes, I copied the SQL from profiler then ran that in SQL MS.
These results are from a new production box. The system is consistently under load. Most reports that users are running are for very small date ranges and return within an acceptable time. However, reports with longer date ranges (the ones that managers and execs often run) are noticeby slower. Whether I run the SP from SQL MS or if I run a report, I assume the same resources are being used by RS.
Keena
Duckboy
Jeanvo
WITH
RECOMPILEAnother one of our developers found a forum where someone had posted the same issue. Their suggestion was to add WITH RECOMPILE to our stored proc. After doing this we have experienced dramatic increases in performance with no unexplained slow periods. Also, before we added WITH RECOMPILE, the processing would occasionally be unevenly distributed between the eight CPUs on the SQL Server. One of the eight would get pegged while the otheres were not. After making the change we have seen an even distribution among all CPUs. Now it's taking the same amount of time to retrieve the data from the report - around 13 seconds.
pinoyz
This is the query ran from within MS:
exec SalesByDivision
@beginDate='2006-12-31 00:00:00:000',
@endDate='2007-02-03 00:00:00:000',
@lyBeginDate='2006-01-01 00:00:00:000',
@lyEndDate='2006-01-28 00:00:00:000',
@storesListName=N'Comp stores',
@departmentsListName=N'Owned merchandise',
@storesCustomList=N'',
@departmentsCustomList=N'',
@delimiter=N',',
@doNotRestate53WeekYear=N'0'
There were 10975 reads, 0 writes, and it took 1001 milliseconds
exec SalesByDivision
@beginDate=''2006-12-31 00:00:00:000'',
@endDate=''2007-02-03 00:00:00:000'',
@lyBeginDate=''2006-01-01 00:00:00:000'',
@lyEndDate=''2006-01-28 00:00:00:000'',
@storesListName=N'Comp stores',
@departmentsListName=N'Owned merchandise',
@storesCustomList=N'',
@departmentsCustomList=N'',
@delimiter=N',',
@doNotRestate53WeekYear=N'0'
There were 601409 reads, 0 writes, and it took 15326 milliseconds
Serend
This is FANTASTIC!!
I was experiencing the same problem - the stored proc would run quickly, however, the report would take up to 15 minutes - and there wasn't much data being returned - fewer than 30 rows and only 15 columns. After adding WITH RECOMPILE to the proc, now the report generates in 15 seconds.
Lars E.Nes
Did you try to just copy the exact text from the profiler (to ensure that typo's and oversights aren't an issue)
Also, is the amount of system resources available possibly an issue
Meaning, when running with just SQL MS, you are just using sql, but when you introduce RS, that's another program eating resources as well.