Tracing Report Execution Performance Analysis Tools

24-30 Publishing Reports to the Web with Oracle Reports Services TABLE ACCESS FULL EMP 1 When you tune data for Oracle Reports, understand that the Oracle RDBMS provides two optimizers: cost-based and rule-based. By default, the cost-based optimizer constructs an optimal execution plan geared towards throughput; that is, process all rows accessed using minimal resources. You can influence the optimizers choice by setting the optimizer approach and goal, and gathering statistics for cost-based optimization. While the cost-based optimizer removes most of the complexity involved in tuning SQL, understanding the distribution of the data and the optimizer rules allow you to choose the preferred method and gives you greater control over the execution plan. For example, in your SQL statement, you could do one of the following: ■ Provide optimizer hints with the goal of best response time; that is, process the first row accessed using minimal resources. ■ Decide that an index is not needed. The Oracle Fusion Middleware documentation provides more information on the database optimizers functionality.

24.3.11 PLSQL

Use the ORA_PROF built-in package to tune your reports PLSQL program units. The procedures, functions, and exceptions in the ORA_PROF built-in package allow you to track the amount of time that pieces of your code takes to run. Example PROCEDURE timed_proc test VARCHAR2 IS i PLS_INTEGER; BEGIN ORA_PROF.CREATE_TIMERloop2; ORA_PROF.START_TIMERloop2; ColorBand_Program_Unit; ORA_PROF.STOP_TIMERloop2; TEXT_IO.PUTFLoop executed in s seconds.\n, ORA_PROF.ELAPSED_TIMEloop2; ORA_PROF.DESTROY_TIMERloop2; END; This procedure creates a timer, starts it, runs a subprogram, stops the timer, and displays the time it took to run. It destroys the timer when finished. Note: For large queries, it is imperative to do one of the following: ■ Activate the cost-based optimizer and gather statistics by using the DBMS_STATS package, the COMPUTER STATISTICS option, or the ANALYZE command. ■ Optimize all SQL following the rules laid out by the rule-based optimizer. Note: For a description of the ORA built-in package see the Oracle Reports online Help. Diagnosing and Tuning Oracle Reports 24-31 Implement PLSQL program units performing a significant amount of database operations as stored database procedures. Stored procedures run directly on the Oracle database and perform operations more quickly than local PLSQL program units. Local PLSQL program units use the Oracle Reports Builders PLSQL parser, then the databases SQL parser, and also include a network trip. PLSQL program units that do not perform any database operations should be coded as locally as possible using the Program Units node in the Object Navigator. Localizing the PL SQL program unit has a performance advantage over executing PLSQL from an external PLSQL library. Use external PLSQL libraries only when the benefits of code sharing can be utilized. The SRW.DO_SQL built-in procedure should be used as sparingly as possible. Each call to the SRW.DO_SQL built-in procedure necessitates parsing and binding the command and opening a new cursor like a normal query. Unlike a normal query, this operation will occur each time the object owning the SRW.DO_SQL built-in procedure fires. For example, a PLSQL block in a formula column calls the SRW.DO_SQL built-in procedure and the data model group returns 100 records. In this case, the parse bind create cursor operation occurs 100 times. Therefore, use the SRW.DO_SQL built-in procedure for operations that cannot be performed using normal SQL for example, to create a temporary table or any other form of DDL, and in places where it will be executed sparingly for example, in triggers that are only fired once per report. The primary reason to use the SRW.DO_SQL built-in procedure is to perform DDL operations, such as creating or dropping temporary tables. For example, have the SRW.DO_SQL built-in procedure to create a table. The tables name is determined by a parameter entered in the Runtime Parameter Form. Example SRW.DO_SQL `CREATE TABLE || :tname ||`ACCOUNT NUMBER NOT NULL PRIMARY KEY, COMP NUMBER 10,2;

24.3.12 Java Stored Procedures

Java stored procedures enable you to implement business logic at the server level; thereby, improving application performance, scalability, and security. Oracle Database allows PLSQL and Java stored procedures to be stored in the database. Typically, SQL programmers who want procedural extensions favor PLSQL and Java programmers who want easy access to Oracle data favor Java. Although Java stored procedures offer extra flexibility, there is some overhead involved. Balance the trade off between performance and flexibility based on your individual needs. Refer to the Oracle Database Java Developers Guide for more information on Java stored procedures.

24.3.13 The Java Importer

Although Oracle PLSQL provides a powerful and productive development environment, it is sometimes necessary to integrate with external application services and providers. As many of these external application services and providers are increasingly offering integration points in Java, Oracle Reports integrates with the Oracle Java Importer to facilitate the invocation of business logic contained in external Note: For a description of the SRW built-in package, including the SRW.DO_SQL built-in procedure, see the Oracle Reports online Help. 24-32 Publishing Reports to the Web with Oracle Reports Services middle-tier Java classes. The Java Importer declaratively creates a PLSQL wrapper package for each class you select and exposes the methods identified in the class through PLSQL functions and procedures. This enables you to instantiate, use, and destroy the Java object instances when the report is run. While this powerful extension insulates you from having to write Java code yourself, there is some overhead involved. Separate PLSQL packages are generated for every class specified. The PLSQL generator performs type translations when it generates the PLSQL packages from the Java methods. Any time a Java object instance is created using the new function in the PLSQL package and generated by the Java Importer, the result is stored in a variable of type JOBJECT. Java Object persistence must be carefully handled because accumulating large numbers of global references without removing them increases the JVMs memory consumption.

24.4 Tuning Reports Server Configuration

This section provides tips for improving the performance and stability of Reports Server, which is responsible for: ■ Accepting the report request from various clients. ■ Scheduling the jobs to run. ■ Managing Oracle Reports engines ■ Managing the cache ■ Managing various destinations ■ Security check ■ Managing the jobstore persistent job data While operating under heavy load, it is essential to tune various Reports Server parameters to optimal values, as follows: 1. Determine optimal values for the initEngine, maxEngine, and minEngine attributes of the engine element in the server configuration file: engine id=rwEng class=oracle.reports.engine.EngineImpl initEngine=1 maxEngine=2 minEngine=1 engLife=50 maxIdle=30 callbackTimeOut=90000 For more information on the engine element, refer to Section 8.2.1.9, engine . The maxEngine value sets the maximum number of processes ready to respond to user requests for running reports. Setting it too low means user requests get queued up and available machine capacity is not fully utilized. Setting it too high means Reports Server will take more than its share of machine capacity from other activities the host also needs to perform, and could cause the operating system to crash. As an example of a simple calculation for number of engines, suppose you have set of reports that takes an average of 10 seconds to run. Input requests to your system varies from 6 reports per minute to 12 reports per minute. In this scenario, the calculations are as follows: ■ initEngine = average time to run report minimum report requests input rate = 1060 6 = 1 ■ maxEngine = average time to run report maximum report requests input rate = 1060 12 = 2