Considering Subreport Execution Time and Performance
There are two types of SubreportsIn-Place and On-Demand. Both of the sample reports created previously in this chapter have been In-Place Subreports. An In-Place Subreport is virtually indistinguishable from the main report components when viewed because it is run at the same time as the main report. In-Place Subreports are displayed as components of the main report like any other report object and require no special business user interaction to view them. On-Demand Subreports, on the contrary, are not executed at the same time as the main report and require user interaction to be viewed.
All In-Place Subreports on a main report are run at the execution time of the main report. In the two examples presented in this chapter, this has clearly not caused any performance problems, but as you might imagine, it could on larger databases and reports. Imagine running the last sample report (with the Product Suppliers Subreport in every Group Header) for a large conglomerate with thousands of products. The Product Suppliers Subreport would need to run thousands of times to complete the presentation of the main report. Moreover, the thousands of supplier Subreports would be unlikely to be used by any given business user and would therefore have run extraneously. An elegant solution to that problem is the use of On-Demand Subreports.
Unlike In-Place Subreports, On-Demand Subreports only execute when a user requests them. They lie dormant until that time. The performance benefits to On-Demand reports are clear; however, it does come at the expense of a less seamless integration than In-Place Subreports and a small delay in viewing because the Subreport executes dynamically after being requested.
Taking the last example, follow these steps to make the Product Suppliers Subreport an On-Demand Subreport:
- Open the most recent sample report if you have closed it.
- Right-click on the Product Suppliers Subreport and select the Format Subreport option. Many familiar formatting options are available here (see Figure 12.6), but click on the Subreport tab.
Figure 12.6. Format Subreport dialog.
- Click the On-Demand Subreport check box to turn on that option. Notice that the On-Demand Caption section becomes un-grayed.
- Click on the On-Demand Caption button (x-2) and type 'Supplier List' (do include the apostrophes) in the Text Editing area. Click on the Save and Close button, and you should now have a main report that resembles Figure 12.7 where the Supplier List link dynamically runs the involved Subreport if and only if a report consumer requests it.
Figure 12.7. Sample report with Linked, On-Demand Suppliers Subreport.
TIP
Careful consideration should be given to report design when deciding between In-Place and On-Demand Subreports. There is a trade-off between the seamless integration of In-Place Subreports and the performance benefits of On-Demand Subreports that must be considered in addition, of course, to the specific requirements of the business users' overall experience.