01.02.2013 Views

Publishing Reports to the Web - Downloads - Oracle

Publishing Reports to the Web - Downloads - Oracle

Publishing Reports to the Web - Downloads - Oracle

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Note: For large queries, it is imperative <strong>to</strong> do one of <strong>the</strong> following:<br />

■ Activate <strong>the</strong> cost-based optimizer and ga<strong>the</strong>r statistics by using<br />

<strong>the</strong> DBMS_STATS package, <strong>the</strong> COMPUTER STATISTICS<br />

option, or <strong>the</strong> ANALYZE command.<br />

■ Optimize all SQL following <strong>the</strong> rules laid out by <strong>the</strong> rule-based<br />

optimizer.<br />

The <strong>Oracle</strong> Application Server documentation provides more information on <strong>the</strong><br />

database optimizer’s functionality.<br />

Methodology<br />

20.1.1.3 PL/SQL<br />

Use <strong>the</strong> ORA_PROF built-in package <strong>to</strong> tune your report’s PL/SQL program units. The<br />

procedures, functions, and exceptions in <strong>the</strong> ORA_PROF built-in package allow you <strong>to</strong><br />

track <strong>the</strong> amount of time that pieces of your code takes <strong>to</strong> run.<br />

Example<br />

PROCEDURE timed_proc (test VARCHAR2) IS<br />

i PLS_INTEGER;<br />

BEGIN<br />

ORA_PROF.CREATE_TIMER('loop2');<br />

ORA_PROF.START_TIMER('loop2');<br />

ColorBand_Program_Unit;<br />

ORA_PROF.STOP_TIMER('loop2');<br />

TEXT_IO.PUTF('Loop executed in %s seconds.\n',<br />

ORA_PROF.ELAPSED_TIME('loop2'));<br />

ORA_PROF.DESTROY_TIMER('loop2');<br />

END;<br />

This procedure creates a timer, starts it, runs a subprogram, s<strong>to</strong>ps <strong>the</strong> timer, and<br />

displays <strong>the</strong> time it <strong>to</strong>ok <strong>to</strong> run. It destroys <strong>the</strong> timer when finished.<br />

Refer <strong>to</strong> <strong>Reports</strong> Builder online help for more information on <strong>the</strong> ORA_PROF built-in<br />

package.<br />

Implement PL/SQL program units performing a significant amount of database<br />

operations as s<strong>to</strong>red database procedures. S<strong>to</strong>red procedures run directly on <strong>the</strong> <strong>Oracle</strong><br />

database and perform operations more quickly than local PL/SQL program units.<br />

Local PL/SQL program units use <strong>the</strong> <strong>Reports</strong> Builder’s PL/SQL parser, <strong>the</strong>n <strong>the</strong><br />

database’s SQL parser, and also include a network trip.<br />

PL/SQL program units that do not perform any database operations should be coded<br />

as locally as possible using <strong>the</strong> Program Units node in <strong>the</strong> Object Naviga<strong>to</strong>r. Localizing<br />

<strong>the</strong> PL/ SQL program unit has a performance advantage over executing PL/SQL from<br />

an external PL/SQL library. Use external PL/SQL libraries only when <strong>the</strong> benefits of<br />

code sharing can be utilized.<br />

The SRW.DO_SQL() built-in procedure should be used as sparingly as possible. Each<br />

call <strong>to</strong> <strong>the</strong> SRW.DO_SQL() built-in procedure necessitates parsing and binding <strong>the</strong><br />

command and opening a new cursor like a normal query. Unlike a normal query, this<br />

operation will occur each time <strong>the</strong> object owning <strong>the</strong> SRW.DO_SQL() built-in<br />

procedure fires.<br />

For example, a PL/SQL block in a formula column calls <strong>the</strong> SRW.DO_SQL() built-in<br />

procedure and <strong>the</strong> data model group returns 100 records. In this case, <strong>the</strong> parse/ bind/<br />

create cursor operation occurs 100 times. Therefore, use <strong>the</strong> SRW.DO_SQL() built-in<br />

Tuning <strong>Oracle</strong> <strong>Reports</strong> 20-7

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!