Crystal Performance - Stored Procedures vs Datasets

Posted on 2006-06-08
Last Modified: 2008-02-01
We have a web application that produces PDF formated reports.
Currently we use .NET datasets to pass the data into Crystal reports in real time.
These can be large and some reports take sveral hours to run (1500+ records) where there are multiple subreports embedded. At time it crashes the server altogether, chewing up resources.
We are trying to come up with a way to delay the report running to a time where server usage is low eg; (9pm)
If I use stored procedures as the datasources in my reports, and pass the parameters out of a database (where they are stored until time allows the report to be run) does this create performance issues. One report may access 5 stored procedures for each record... therefore 7500 calls on a large report.

I want to know if this is faster, slower...or a stupid way of addressing our issue.
Any input is appreciated...though please dont give generic links to examples.
Question by:Milkus1
  • 2
  • 2
  • 2
  • +2
LVL 10

Assisted Solution

Spykair earned 50 total points
ID: 16867535
>One report may access 5 stored procedures for each record... therefore 7500 calls on a large report.
I know that a report can only have one SP as a datasource. I assume that the other 4 SP's are called from subreports. Subreports will definitely have an influence on the performance of your report. The more subreports you have, the slower your report will run.

LVL 42

Accepted Solution

frodoman earned 350 total points
ID: 16869512
It sounds like you're calling multiple subreports for each record on your report, is that correct?  If so, then I don't think you'll see any performance gain by moving to stored procedures (it might even slow down a little because of the initialization time).

With a report structured this way, almost certainly the bulk of the time is within Crystal itself so changing the datasource isn't going to have a significant impact.  If you really want to boost performance, look for a way that you can eliminate some of the subreports.  One suggestion to look at would be if you can return some of the data being pulled in the subreports with your main dataset (this is where a stored procedure might help by enabling you to do this).  Although this often means some duplicate data gets sent in, it may be much more efficient than 7500 subreport calls.

LVL 26

Assisted Solution

by:Kurt Reinhardt
Kurt Reinhardt earned 50 total points
ID: 16870909
frodoman and spykair offer good advice.  Subreports can be useful, but they can also be very detrimental.  For example, a subreport makes a call to the database once for every occurence of the section in which it is housed.  For example, if a subreport is in the Report Header, it will make one call to the db.  If it is in the Page Header, it will make one pass for every page in the report.  If it is in the detail section, then it will make one pass for every detail record returned - if there are 50,000 records returned, it will make 50,000 passes to the database.  Obviously, this isn't ideal.

Before you consider changing from a .NET dataset to a stored procedure, I would suggest you analyze the actual report requirements and design and see if there's a better way to gather and return the data.  As frodoman stated, stored procedures can help to eliminate the need for subreports.  Additionally, if you simply need to return a single value and you're using a subreport to get it, a SQL Expression field might help.

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

LVL 100

Assisted Solution

mlmcc earned 50 total points
ID: 16874645
Agree.  The report will probably run better if run when the server has less load but it will still use similar amounts of resources it just won't be competing for them.

The stored procedure should run fatser since but as pointed out by frodoman, the gain will be outweighed by the complexity of the report and the number of calls.


Author Comment

ID: 16883387
All good advice, thankyou. Point splitting looks likely ;0)

If it helps the report produces a list of applicants for a particular hospital for various positions.
So the report is grouped by 'Position' and inside each applicant's details is subreports for

1.List of qualifications (0...5 records)
2. List of previous employment (0...10 records)
3. List of preferences for positions (1-5 records)
4. List of referees (3 records)
5. List of referee replies (3 records)

These are also accompanied by up to 100 other fields eg : surname, DOB, etc

What would be the recommended approach, based on the fact there may be 1500+ applicants.

LVL 42

Expert Comment

ID: 16884703
It's difficult to say the 'best' approach w/out being in your shoes.  One thing I would consider doing is to make all of the applicant's details a single subreport.  Create a stored procedure that returns for every employee a single record structured like this:

Qualification1, Qualification2, Qualification3, Qualification4, Qualification5, PrevEmploy1, PrevEmploy2, ... etc.

Have your SP return empty strings or even a single space character for any field w/out data so you're always getting back the same fields, even if nothing is in them.  You can then layout your subreport with a very large details section and arrange all of these fields however you want to see them.  This gives you all of the same data but only 1 subreport per employee - as long as the SP is efficient this will be a tremendous improvement.

You might also consider making this subreport "on-demand" so it only runs if you're interested in this person and click on their name.  I don't know though if that makes sense for your situation.


LVL 100

Expert Comment

ID: 16938815
Glad i could help

LVL 10

Expert Comment

ID: 16939762
Glad to help.


Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now