19.06.2013 Views

DB2 UDB for z/OS Version 8 Performance Topics - IBM Redbooks

DB2 UDB for z/OS Version 8 Performance Topics - IBM Redbooks

DB2 UDB for z/OS Version 8 Performance Topics - IBM Redbooks

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Application programmers need to be able to make sure that SQL will per<strong>for</strong>m correctly, but in<br />

many cases they should not have the authority to read the actual data the SQL will be<br />

selecting or updating, <strong>for</strong> example, sensitive payroll data. OWNER(SYSADM)<br />

DYNAMICRULES(BIND) allows a user to EXPLAIN SQL statements without having the<br />

privilege to execute those SQL statements. However, the drawback of this setting is that the<br />

owner becomes the default qualifier <strong>for</strong> unqualified tables and views inside the SQL.<br />

PTFs UQ92322 (<strong>DB2</strong> V7) and UQ92323 (<strong>DB2</strong> V8) <strong>for</strong> the two APARs PQ90022 and<br />

PQ93821 add a new sample stored procedure called DSN8EXP that can be used to work<br />

around these constraints. DSN8EXP accepts an SQL statement of up to 32700 single-byte<br />

characters, passed as an input parameter from its caller. It first sets the current SQLID to<br />

locate EXPLAIN tables, then it issues the EXPLAIN statement <strong>for</strong> the input SQL. You can<br />

optionally let the stored procedure parse the SQL and add the qualifier ahead of those<br />

unqualified tables/views if there are any unqualified tables/views in the SQL. For<br />

insert-within-select and common table expressions, you need to disable the parsing function,<br />

and add the qualifier manually. DSN8EXP returns the SQLCODE, SQLSTATE, and diagnostic<br />

text from the EXPLAIN by output parameter.<br />

Visual Explain <strong>for</strong> <strong>DB2</strong> <strong>for</strong> z/<strong>OS</strong> <strong>Version</strong> 8 provides an easy-to-use interface to call the<br />

DSN8EXP stored procedure.<br />

Installation<br />

This PTF also provides a new sample job called DSNTEJXP that you can use to prepare and<br />

bind the DSN8EXP stored procedure. DSNTEJXP is not customized by the <strong>DB2</strong> installation<br />

CLIST. See the prolog of DSNTEJXP <strong>for</strong> guidance on customizing it to run at your site.<br />

Running DSN8EXP from Visual Explain<br />

In the Subsystem Parameters Panel there are fields to specify the stored procedure's schema<br />

name and procedure name. When all necessary fields are filled in the TuneSQL panel, note<br />

there is a field called "Table qualifier <strong>for</strong> Explain stored procedure:" When this field has a<br />

non-blank value, it is used as the input parameter QUALIFIER <strong>for</strong> the stored procedure and<br />

the parsing function will be enabled; if this field is blank, then the parsing is disabled. There is<br />

also a button called "Explain with stored procedure" shown in the TuneSQL panel, which<br />

actually invokes the EXPLAIN stored procedure. The original EXPLAIN button still issues<br />

normal Explain statements.<br />

5.6.9 PLAN_TABLE access via a <strong>DB2</strong> alias<br />

Up to V7, you did not have the capability to access Explain tables with different OWNER and<br />

QUALIFIER names. OWNER refers to the creator of the EXPLAIN table; QUALIFIER refers to<br />

the user that issues the EXPLAIN statement. A limitation of the EXPLAIN command has been<br />

that only the owner of the EXPLAIN tables can issue the EXPLAIN statement to populate<br />

his/her tables. This has prevented you from being able to consolidate your plan tables under a<br />

single AUTHID.<br />

Starting with V8, you can use the ALIAS mechanism to populate EXPLAIN tables created<br />

under a different AUTHID. The following external EXPLAIN tables can now have aliases<br />

defined on them:<br />

► PLAN_TABLE<br />

► DSN_STATEMNT_TABLE<br />

► DSN_FUNCTION_TABLE<br />

The alias name must have the <strong>for</strong>mat userid.table_name where tablename can be<br />

PLAN_TABLE, DSN_STATEMNT_TABLE or DSN_FUNCTION_TABLE.<br />

Chapter 5. Availability and capacity enhancements 259

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

Saved successfully!

Ooh no, something went wrong!