Report Generation, very slow performance.

It takes too much time for the reports to load is what i experienced.
I wrote 2 java files to develop a report.

In the first report i designed the .jrxml file using iReport.
All the fields were made in the design time. A db connection
was made and a simple 'Select' query was executed.
What i noticed is that the ' JasperCompileManager.compileReport(design); '
takes some time to compile. It took 5 seconds to compile.
2 secs to fill the report and 2 secs to view.
So in all it took more than 9 secs for the report to appear on the screen.
I feel 9 secs is too slow for a report as simple as this to generate.

In the second report i took a blank .jrxml file without any fields.
Using the jasperreports api i designed all the fields at run-time.
I declared all parameters on runtime too. The query is also set at runtime.
It took 13 secs to compile, 5 secs to fill and 2 secs to view.
So in all 20 secs for the report to appear.
20 secs is too long.

Is this normal. Is there any way to boost the performance ??
Even the slightest intention of help would be highly appreciated.
coldblood22's picture
Joined: Jan 13 2008 - 2:31pm
Last seen: 15 years 8 months ago

4 Answers:

In the first report, you can try using the compiled reports (*.jasper files), instead of .JRXML files.

In the code below the reportFile is pointing to the *.jasper file. Here is the code that I used:

JasperReport jasperReport = (JasperReport) JRLoader.loadObject(reportFile);
JasperPrint jasperPrint = net.sf.jasperreports.engine.JasperFillManager.fillReport(jasperReport, parametermap, new net.sf.jasperreports.engine.JRResultSetDataSource(rs));

Good luck!!
ns69's picture
Joined: Aug 23 2007 - 7:23am
Last seen: 16 years 1 month ago
Hey ns69, thanks a lot for your help.
I checked using the .jasper files and the execution time taken was very less. Now the problem is that most of the reports i am designing is at runtime so i need a solution for that. Thanks again.
coldblood22's picture
Joined: Jan 13 2008 - 2:31pm
Last seen: 15 years 8 months ago
If you need to generate and compile reports at run-time, make sure you use the JDT-based report compiler (more details in [url= FAQ).

If the compilation time is still a problem, you should consider (if possible) implementing a cache of compiled reports so that the number of report compilations is reduced to minimum.

lucianc's picture
Joined: Jul 17 2006 - 1:10am
Last seen: 11 hours 55 min ago

why not we user .jasper files instead of jrxml files. if u use jrxml files first we have to compile and we have to keep in the memory for the future refernce calls instead of use jasper files(compiled files), it will be save

1. no need to compile
2. no need to keep in cache.

if any thing wrong, please let me know....
hari.sunku's picture
Joined: Mar 10 2008 - 5:58am
Last seen: 15 years 6 months ago