SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Slow queries in reporting services! Bug or feature?


Slow queries in reporting services! Bug or feature?

Author
Message
Oliver Heilmann
Oliver Heilmann
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
Points: 9 Visits: 96
Thanks again for all the good ideas and hints.
I took a look at the statements with the profiler, but I can see no difference between the statements. I also took a look at the system with Filemon and Procmon and I can see, that the query in the management studio only causes minor drive access and the query in the reporting services causes much more drive access. To me it still looks like doing an index scan vs. a full table access, but I am not sure about it. I will know try to switch of all indexes and look if the queries take the same time...

Regards
Oliver
GilaMonster
GilaMonster
SSC Guru
SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)

Group: General Forum Members
Points: 90935 Visits: 45284
And you see the one from reporting services with duration = 60 sec?

Can you perhaps post the query?

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Oliver Heilmann
Oliver Heilmann
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
Points: 9 Visits: 96
Hi,

here are the results. First picture (ManagementStudio.jpg) shows statement and result for direct execution in the management studio. The second picture shows the result for the reporting services. You can clearly see the difference 3,2s vs. 49,5s.
I also took a look at the index usage statistics and I can see that the index is used by the reporting services... Where are the missing 46 seconds... Cool

Regards
Oliver
Attachments
ManagementStudio.jpg (169 views, 155.00 KB)
ReportService.jpg (167 views, 187.00 KB)
jegu
jegu
SSC-Enthusiastic
SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)

Group: General Forum Members
Points: 116 Visits: 57
Hi,
As you can see from both images the reporting service is using the dynamic SQL. I hope if you create stored procedure will increase the performance.
Oliver Heilmann
Oliver Heilmann
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
Points: 9 Visits: 96
Hi,

Yes, you've got it! I am impressed, the report is now finished in 7 seconds! Collecting the data now only takes 0,3s in reporting services, 10 times faster than it is in management studio. I am glad to have this result, but I must confess, that I do not really understand it. Do you have more information about this topic or some good links?
I think I will use stored procedures more often in the future...

Regards
Oliver
jegu
jegu
SSC-Enthusiastic
SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)

Group: General Forum Members
Points: 116 Visits: 57
Hi,
I don't have any links as of now and i hope to update in the future. In order to go deeper we have to fully understand how the reporting service is executing the queries.

I suggest you to use SP's for ease of maintainability. Changing the RDL file is not easy once it's deployed. So whenever you develop reports in Reporting services design in a such way that you are not touching the RDL when you want to implement new changes.

Thanks,
Jegatheesh
Dave Balsillie
Dave Balsillie
Mr or Mrs. 500
Mr or Mrs. 500 (531 reputation)Mr or Mrs. 500 (531 reputation)Mr or Mrs. 500 (531 reputation)Mr or Mrs. 500 (531 reputation)Mr or Mrs. 500 (531 reputation)Mr or Mrs. 500 (531 reputation)Mr or Mrs. 500 (531 reputation)Mr or Mrs. 500 (531 reputation)

Group: General Forum Members
Points: 531 Visits: 430
Just for the record, I'd note that the RS SQL Statement had the index hint, while the MS SQL Statement did not.

sp_executesql generates a query plan "more likely to be reused". (http://msdn.microsoft.com/en-us/library/ms175170.aspx). It's possible, that based on your tests, the state of your statistics and and your stored procedure cache, you were simply stuck with different query plans.

I'd look at the query plans for these statements separately. One technical point, is that in RS, your parameters were datetime while the MS parameters are string (hard coded).

Also, in general I'd like to understand what you're trying to get at with the "DATEADD" criteria in your where statement. I'm not sure if the optimizer would pick up the index properly (assuming XSALESDATETIME is part of the special index.) I think you're doing a date range, but I'm not sure.
Oliver Heilmann
Oliver Heilmann
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
Points: 9 Visits: 96
Hi,

thanks to all for their help and tips.

You are right, the RS statement still had the index hint, but it did not help. The result is the same without the index hint.

You are also right, that there are slight differences. Yes, the date is hard coded as string in managements studio, but is a datetime type in RS. I hope this does not make a difference.

The date part of the statement looks a little bit strange, I know. The original data has a timestamp with hour, minute and second, but we are only interested in the data for the whole day. I read about this little trick somewhere (maybe here at SQLCentral...). But I am sure the index works with this, because without it, the same statement takes some minutes to finish...

I am happy with the result now. All I want to understand is, why is SQL Server 2005 behaving differently if the statement is executed directly or in a stored procedure. I will search the web for some more information.

Regards
Oliver
torkaman
torkaman
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 6
I have the same problem with reporting services. I am not much of a write, so I send you to the following URL, it talks about a phenomenon called parameter sniffing, word reading
http://www.lockergnome.com/sqlsquirrel/2007/12/14/victim-of-parameter-sniffing/
torkaman
torkaman
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 6
CoolI have the same problem with reporting services. I am not much of a write, so I send you to the following URL, it talks about a phenomenon called parameter sniffing, word reading
http://www.lockergnome.com/sqlsquirrel/2007/12/14/victim-of-parameter-sniffing/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search