views:

155

answers:

5

When I execute a T-SQL query it executes in 15s on sql 2005.

SSRS was working fine until yesterday. I had to crash it after 30min.

I made no changes to anything in SSRS.

Any ideas? Where do I start looking?

A: 

Have you tried making the query a stored procedure to see if that helps? This way execution plans are cached.

Updated: You could also make the query a view to achieve the same affect.

Also, SQL Profiler can help you determine what is being executed. This will allow you to see if the SQL is the cause of the issue, or Reporting Services rendering the report (ie: not fetching the data)

Wayne
A: 

There are a number of connection-specific things that can vastly change performance - for example the SET options that are active.

In particular, some of these can play havoc if you have a computed+persisted (and possibly indexed) column. If the settings are a match for how the column was created, it can use the stored value; otherwise, it has to recalculate it per row. This is especially expensive if the column is a promoted column from xml.

Does any of that apply?

Marc Gravell
No, but thank you for your comment. I will make sure that I stick to your recommendations on my other reports.
Greg
A: 

The first port of call for any performance problems like this is to get an execution plan. You can either get this by running an SQL Profiler Trace with the ShowPlan Xml event, or if this isn't possible (you probably shouldn't do this on loaded production servers) you can extract the cached execution plan that's being used from the DMVs.

Getting the plan from a trace is preferable however, as that plan will include statistics about how long the different nodes took to execute. (The trace wont cripple your server or anything, but it will have some performance impact)

Kragen
A: 

Are you sure the problem is your query? There could be SQL Server problems. Don't forget about the ReportServer and ReportServerTempDB databases. Maybe they need some maintenance.

Mozy
+1  A: 

Start your query in SSIS then look into the Activity Monitor of Management Studio. See if the query is currently blocked by any chance, and in that case, what it is blocked on.

Alternatively you can use sys.dm_exec_requests and check the same thing, w/o the user interface getting in the way. Look at the session executing the query from SSIS, check it's blocking_session_id, wait_type, wait_time and wait_resource columns. If you find that the query is blocked, the SSIS has no fault probably and something in your environment is blocking the query execution. If on the other hand the query is making progress (the wait_resource changes) then it just executes slowly and its time to check its execution plan.

Remus Rusanu
Thank you very much Remus
Greg