Reputation: 571
as the title suggests, I have a performance problem when generating Jasper Reports in batches. A single report for say a single customer's bank statement takes 2 seconds to generate. To generate for 50 customers I have to generate each one and subsequently merge them all into a single file which i subsequently pass to a servlet, and this takes 2 x 50 seconds (Close to 2 Minutes). Assuming of course there's no traffic on my server or internet issues whatsover. Is there a way I can improve the performance of batch reporting like in my case? Are there special features of Jasper Reporting that I have not yet explored?
What I have done: 1. I've been able to save meaningless calls to the database to fetch much needed records, and narrowed it down to just one call. (And to display this on the User Interface takes roughly 4 seconds for the entire data to display).
I found a short article on Jasper's batch export using a List
of JasperPrint
Objects. But this did not improve the performance at all. I thought exporting the report once would help as opposed to exporting each single report once and subsequently merging the PDF bytes. But this was not the case.
I have explored grouping on the JRXML file so the entire data can be rendered once, but this also fails horribly as I need the detail band to be iterated over, not just for customers, but also for each customer's data.
Any help in improving the performance of batch exports for Jasper Reports would be appreciated.
Upvotes: 2
Views: 5291
Reputation: 571
After some research and a lot of testing, I discovered Jasper wasn't really the problem. After achieving Report Grouping (gathering all the data and generating from one .jasper file at once), I discovered it didn't make much of a difference from generating individual reports and merging together with a PDFMerger
library. What made the difference was Code optimization. If one customer's report is generated in 2 seconds, I discovered it could be made better. These are the following steps I took to achieve this.
These two alone made the difference.
Upvotes: 1