views:

155

answers:

2

I have a query that takes roughly 2 minutes to run. It's not terribly complex in terms of parameters or anything, and the report itself doesn't do any truly extensive processing. Basically just spits the data straight out in a nice format. (Actually one of the reports doesn't format the data at all, just returns a flat table meant to be manipulated in excel.)

It's not returning a massive set of data either.

Yet the report takes upwards of 30 minutes to run.

What could cause this?

This is SSRS 2005 against a SQL 2005 database btw.

EDIT: OK, I found that with the addition of WITH (NOLOCK) in the report it takes the same time as the query does through SSMS. Why would the query be handled differently if it's coming from reporting services (or visual studio on my local machine) than if coming from SSMS on my local machine? I saw the query running in Activity Monitor a couple times in SLEEP_WAIT mode, but not blocked by anything...

EDIT2: The connection string is:

Data Source=SERVERNAME;Initial Catalog=DBName

A: 

Is it definitely the query taking a long time to run, or is the processing being done by the server that is slow? Some reports call queries multiple times. For instance, if you have a subreport inside a of a paging list control, each page of that report calls the query separately. So maybe there's something the report is doing with the data causing the delay?

lividsquirrel
The report only calls the query once... and as I said the report doesn't do much processing of the data. Once I added WITH NOLOCK to the query the report ran in under 2 minutes...
Telos
A: 

How large is the data set that is returned by your query? If it is very large the majority of the time that is taken on the report server could be related to the time it takes the report to render. To be sure you could look at the ExecutionLog table on the report server to see if the TimeRendering is a large number in comparison to the overall execution time.

Greg Lorenz
Not that large, and besides why would NOLOCK affect the speed of the report then?
Telos