Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Sub Report Query Post Reply Post New Topic
Author Message
GowthamSen
Groupie
Groupie


Joined: 03 Jun 2009
Location: India
Online Status: Offline
Posts: 65
Quote GowthamSen Replybullet Topic: Sub Report Query
     Posted: 12 Jun 2009 at 9:30am
Hi,
 
I have one crystal report. In that I have many sub reports.
 
Here each sub report is using one separate query.
 
This is taking more time to execute the queries.
 
When I See the queries, I found that, I can merge few queries into a single query, so that it would improve the peformance.
 
Can we assing one query as input for all sub reports? In such scenario will the report execute the query only once or will it run for each sub report?
 
 
Thank you
Regards,

Gowtham Sen.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 12 Jun 2009 at 9:40am
I am pretty sure it will executeone per time any sub report is created within the main report that uses it. So if you have a sub-report that is in a group header that uses 1 query and that header si repeated 10 times in the main report it will run that query 10 times. If you place another subreport in the details section of the main report and this subreport uses the same query and there are 100 detail rows in your main report the query will now be run 110 times.
Sub reports can really bog the performance down. When possible it is more efficient to use stored procedures or views to massage data in a way that you can display it in a report with out having to use sub-reports.
IP IP Logged
GowthamSen
Groupie
Groupie


Joined: 03 Jun 2009
Location: India
Online Status: Offline
Posts: 65
Quote GowthamSen Replybullet Posted: 12 Jun 2009 at 9:54am
Thank you DBlank.
 
So, Is it the same case for keeping sub reports in Report footer and Report Header section as it is for group header?
 
If you don't mind.. could you please explain how it is different with stored procedures?  Actually I am new to Cyrstal reports.
 
Thank you
Regards,

Gowtham Sen.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 12 Jun 2009 at 10:16am

Basically every time that subreport is called by the main report it is going to execute any/all queries that are in that sub report. If you place the sub report in a header it is most likely to going to be run fewer times (e.g. 1 time for a report header) and therefore have less impact on the overall performance.

Often a sub report is used to deal with crystal table join problems that are causing duplicate records to appear or a select statement inside crystal is making the data scope to small or forcing an outer join to be an inner join. There is just not as much flexibility in crystal to handle different ways to join or manipulate all the raw data. Sometimes using a stored proc or a view in SQL as the data source instead of the original tables can allow you to pare it down to what you need without resorting to a sub-report.


Edited by DBlank - 12 Jun 2009 at 10:18am
IP IP Logged
GowthamSen
Groupie
Groupie


Joined: 03 Jun 2009
Location: India
Online Status: Offline
Posts: 65
Quote GowthamSen Replybullet Posted: 12 Jun 2009 at 10:20am
Thank you so much Clap
Thank you
Regards,

Gowtham Sen.
IP IP Logged
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