Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Writing Code
Message Icon Topic: Slow, but is it normal? Post Reply Post New Topic
Author Message
utkuozan
Newbie
Newbie
Avatar

Joined: 12 Mar 2007
Location: Turkey
Online Status: Offline
Posts: 7
Quote utkuozan Replybullet Topic: Slow, but is it normal?
    Posted: 28 Jun 2007 at 12:19am
I am using Crystal Reports .NET 2005 to generate a report in a databse software. The thing is that one of my reports respond very slow.  understand the issue but is this much of slowness normal????
 
Let me tell a bit about the structure I use. My report consists of two Views formed in SQL Server 2005.
=============
View1:
Consists of another view and a table with 1 relation
 
VIEW1 = View0 + TableA
--------------------------
View 0 consists of 8 tables with 11 relations.
 
VIEW0 = Table1 + Table 2 + ... + Table 8
================
View 2 consists of 8 tables of
 
4 x Table AA
2 x TableBB
1 x Table CC
1 x Table DD
 
with 7 relations.
 
These two views are fed through the report and results are displayed according to the field values returned.
 
As I run these views in SQL Management studio
 
View1 finishes task and returns results in about 20 seconds with 768 results and
View 2 finishes task and returns results in about 1 second with 44 results
 
But the thing is that when I feed these resources into my software and run it I get the report in about total 400 seconds!!!
 
I know that there is a heavy load of queries to retrieve data, but isn't slowing down the process about 20 times a bit much????
 
P.S. : The time 400 seconds does not incluse the code execution time. It is the time that the parameters are set, codeaork is done and form is set to be shown.
Utku Ozan ÇANKAYA
utkuozan@gmail.com
IP IP Logged
jkwrpc
Senior Member
Senior Member


Joined: 19 Jun 2007
Location: United States
Online Status: Offline
Posts: 432
Quote jkwrpc Replybullet Posted: 28 Jun 2007 at 9:38am

What is correct for execution time somewhat hard to assess. Factors not in the SQL Server data dump are things all related to the presentation of the data. That is field and page formatting. These are all things that I am sure you have factored.

 
What I do find is when working with the multiple tables in a single report is that you must give a lot of thought as to which on serves as the master table in you CR layout. I have found this can really impact my report performance even though a straight SQL query shows good performance.    Like you I have had pure queries run in seconds and reports take many minutes to generate. Changing the order the joins has brought the report in line with the query allowing for the extra formatting time.
 
Hope it is of help
 
Regards,
John W.
 
 
 
 
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 28 Jun 2007 at 11:16am
I suggest grabbing a book on CR that discusses SQL optimization. There are so many factors that could affect this. But one thing that jumps out at me is to ask how many rows are in our final report? You have so many tables and it looks like there might be a many to many relationship. If so, this can create a cartesian product on the report side and the report will have tons of data to churn through as it builds the report. If so, the is putting quite a load on your reporting control. I would look at typical optimization factors about using a SQL command so that the join is done on the server and CR only gets the final resultset. Also check out if you have any selection filters or grouping which could be optimized by using SQL Expressions or passing more work to the server.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
utkuozan
Newbie
Newbie
Avatar

Joined: 12 Mar 2007
Location: Turkey
Online Status: Offline
Posts: 7
Quote utkuozan Replybullet Posted: 28 Jun 2007 at 11:42pm
Well, after some examinations and some optimization ideas I tried to figure out how to gain some performance.
 
First of all I realized that View0 only returns the results in about 6 seconds. But when I performed the View1 again I have seen that I have mistaken. Apparently it seems that 20 seconds is totally wrong. The problem is that the SQL Server performs the query, returns some part of the results, pauses for execution, returns some other portion etc. in about 256 rows chunks. 20 seconds was the time elapsed for some portion only, and I have mistaken to miss that the whole query has not been finalized yet.
 
After a full query execution I figured that the total execution time is about 250 seconds as well. After a discussion with my boss we have changed the query style. Instead of forming the View1 from View0 we have created a table that has the same structure with the resulting View0. Then created a stored procedure that performs the following:
 
1 - Empty the table contents
2 - Run the query as we create View0 and push data into the table
3 - Save data contents
4 - Now perform another query to retireve the results that the View1 should bring.
 
Then we have,
bound this stored procedure to the report as data source.
 
Results: The stored procedure completes the whole task in about amazing 7 seconds versus View's 250 seconds. But the performance increase while displaying the report was actually not that amazing. But eventually we have managed to gain a 35%, reducing the total time down to about 270 seconds. Still too long to view a report but preferable against View's 400 seconds!!!
 
There seems that, there is not an easy or significant way to improve the performance for us at the moment. But why is the report so slow????
As BrianBischof quoted
 
Originally posted by BrianBischof

But one thing that jumps out at me is to ask how many rows are in our final report?
 
the answer lies in the number of results returned. My view or stored procedure returns about 4000 lines of records which spans more than 80 pages of report. Even the query is completed at a considerable time, preparing the forms and displaying 4000 records take too long I guess. Since I don't have much experience on Crystal Reports, that idea might be false, but it seems the only way that makes a sense explanation.


Edited by utkuozan - 28 Jun 2007 at 11:47pm
Utku Ozan ÇANKAYA
utkuozan@gmail.com
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 29 Jun 2007 at 12:21am
Thanks for the update. I've never encountered SQL running a view in chunks like that. Maybe your server is multi-processing your request with others and sharing the process time across queries? I don't know. But very interesting behavior.

Re the report, sounds like you probably have things optimized. It's just a damn big report! However, there is still the possibility that you are showing the total number of pages at the bottom of each page and this slows down the display of the first page b/c it has to internally create the entire report beforehand. Get rid of 'Page N of M' and the first page will load up much faster. There are various other optimization techniques, but without knowing your report design there is no telling which ones apply to you. Hmmm... Do you have any formulas that can be calculated using SQL Expressions? That would help. Also, are you concatenating fields within a text object? It's faster to do that with a formula. And using the Count summary function slows things down too. But either way, you just have a really big report and it takes time to process.

Let us know if you make any other optimization techniques help things out.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
utkuozan
Newbie
Newbie
Avatar

Joined: 12 Mar 2007
Location: Turkey
Online Status: Offline
Posts: 7
Quote utkuozan Replybullet Posted: 29 Jun 2007 at 12:49am

Actually I would like to thank everybody here, for your help. Regarding to your last message;

Currently I am not running the SQLServer from a remote location. During development process I am using the local database on my computer. But my processor is one of the Dual Core types and might that be acting like a multi-processor?

And your guess was right. I was using 'Page N of M' and removing that gained me another 10-15 seconds.
 
About the functions. If you mean the SQL functions of Crystal Reports, I don't have any on form. But at the SQL Management Studio, at the View2 there are no functions but there are two type conversions and two string concatenations.
 
In the View1, I have 3 Scalar-valued functions, with 32 columns returned of which 6 are aliased.
Utku Ozan ÇANKAYA
utkuozan@gmail.com
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 29 Jun 2007 at 9:36am
Another thing that will slow down a report is using a formula as a group, a sort, or a selection criteria.  Crystal doesn't pass those along to the server, it will bring ALL of the records to the workstation where the report is being processed and then churn through them there to complete the report.
 
-Dell
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.