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.

Methodology<br />

how <strong>the</strong> database executes <strong>the</strong>se statements. If you are less proficient in SQL, use <strong>the</strong><br />

Data Wizard and Query Builder in <strong>the</strong> <strong>Reports</strong> Builder. However, <strong>the</strong> wizard cannot<br />

prevent inefficient SQL from being created. For example, SQL that does not use<br />

available indexes.<br />

To tune your report's SQL, use <strong>the</strong> <strong>Oracle</strong> database's trace functionality. SQL tracing<br />

allows you <strong>to</strong> determine <strong>the</strong> SQL statement sent <strong>to</strong> <strong>the</strong> database as well as <strong>the</strong> time<br />

taken <strong>to</strong> parse, execute, and fetch data. Once a trace file is generated, use <strong>the</strong> TKPROF<br />

database utility <strong>to</strong> generate an EXPLAIN PLAN map. The EXPLAIN PLAN map<br />

graphically represents <strong>the</strong> execution plan used by <strong>Oracle</strong> Optimizer. For example, <strong>the</strong><br />

<strong>Oracle</strong> Optimizer shows where full table scans have been used. This may prompt you<br />

<strong>to</strong> create an index on that table depending on <strong>the</strong> performance hit.<br />

To turn on SQL tracing inside <strong>Reports</strong> Builder, add a report-level formula column<br />

named SQL_TRACE with <strong>the</strong> following code:<br />

SRW.DO_SQL(‘ALTER SESSION SET SQL_TRACE=TRUE’);<br />

return(1);<br />

Note: You can also call SQL_TRACE using ei<strong>the</strong>r a Before Report<br />

Form trigger, or a Before Parameter Form trigger.<br />

The following EXPLAIN PLAN map was generated using <strong>the</strong> database’s SQL trace<br />

facility. Refer <strong>to</strong> <strong>the</strong> SQL Language Reference and Programming documentation for more<br />

information.<br />

Example<br />

The statement being executed is:<br />

SELECT e.ename, d.dname<br />

FROM emp e, dept d<br />

WHERE e.deptno(+) = d.deptno<br />

The EXPLAIN PLAN generated is:<br />

OPERATION OPTIONS OBJECT_NAME POSITION<br />

------------------ ----------- --------------- --------<br />

SELECT STATEMENT<br />

MERGE JOIN OUTER 1<br />

SORT JOIN 1<br />

TABLE ACCESS FULL DEPT 1<br />

SORT JOIN 2<br />

TABLE ACCESS FULL EMP 1<br />

When you tune data for <strong>Oracle</strong> <strong>Reports</strong>, understand that <strong>the</strong> <strong>Oracle</strong> RDBMS provides<br />

two optimizers: cost-based and rule-based. By default, <strong>the</strong> cost-based optimizer<br />

constructs an optimal execution plan geared <strong>to</strong>wards throughput, i.e., process all rows<br />

accessed using minimal resources. You can influence <strong>the</strong> optimizer's choice by setting<br />

<strong>the</strong> optimizer approach and goal, and ga<strong>the</strong>ring statistics for cost-based optimization.<br />

While <strong>the</strong> cost-based optimizer removes most of <strong>the</strong> complexity involved in tuning<br />

SQL, understanding <strong>the</strong> distribution of <strong>the</strong> data and <strong>the</strong> optimizer rules allow you <strong>to</strong><br />

choose <strong>the</strong> preferred method and gives you greater control over <strong>the</strong> execution plan.<br />

For example, in your SQL statement, you could do one of <strong>the</strong> following:<br />

■ Provide optimizer hints with <strong>the</strong> goal of best response time, i.e., process <strong>the</strong> first<br />

row accessed using minimal resources.<br />

■ Decide that an index is not needed.<br />

20-6 <strong>Oracle</strong> Application Server <strong>Reports</strong> Services <strong>Publishing</strong> <strong>Reports</strong> <strong>to</strong> <strong>the</strong> <strong>Web</strong>

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

Saved successfully!

Ooh no, something went wrong!