Print Page | Close Window

Efficient use of subreport

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=14983
Printed Date: 26 Apr 2024 at 11:31pm


Topic: Efficient use of subreport
Posted By: [tupe]
Subject: Efficient use of subreport
Date Posted: 21 Nov 2011 at 1:04am
Hi,

I've created a Inventory Turnover report with CR XI.
The main report queries information regarding item stock balance in given period. Fields are grouped by the item and placed in the group footer.
The sub report queries the items and sums up the ordered quantity with in last 365 days. This is also grouped by the item on sub report and placed on the group header on the main report. The report are linked with grouped items.

The report works fine but it is really slow because sub report is run for every item one by one.
Is there better way to do this?
Is it possible to accomplish this so that the sub report is run only once?



Best regards,
Tupe



Replies:
Posted By: lockwelle
Date Posted: 21 Nov 2011 at 5:15am
technically, no, the subreport needs to run each and every time, but there are ways around hitting the database.
 
You can use a stored procedure to fetch all the data into one really wide dataset, then you can usually group and return the same results as the subreport without actually hitting the database (or even a subreport).
 
You could have the subreport, but if you report is called from an application, you can have the application get the data and set the datasource of the report, this way, the reports gets the data, but you control the data/hits to the database.
 
If I was writing the report for a stand alone report (no application) I would probably opt for the wide dataset as that has only 1 hit to the database, and you can usually get everything to display without needed to resort to a subreport.
 
HTH



Print Page | Close Window