10.12.2012 Views

Application Programming and SQL Guide - Kmlinux

Application Programming and SQL Guide - Kmlinux

Application Programming and SQL Guide - Kmlinux

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.

|<br />

|<br />

|<br />

|<br />

|<br />

|<br />

|<br />

|<br />

Column correlation . . . . . . . . . . . . . . . . . . . . . . 700<br />

DB2 predicate manipulation . . . . . . . . . . . . . . . . . . . 703<br />

Predicates with encrypted data . . . . . . . . . . . . . . . . . 707<br />

Using host variables efficiently . . . . . . . . . . . . . . . . . . . 707<br />

Changing the access path at run time . . . . . . . . . . . . . . . 707<br />

Rewriting queries to influence access path selection . . . . . . . . . . 710<br />

Writing efficient subqueries . . . . . . . . . . . . . . . . . . . . 713<br />

Correlated subqueries . . . . . . . . . . . . . . . . . . . . . 713<br />

Noncorrelated subqueries . . . . . . . . . . . . . . . . . . . 714<br />

Conditions for DB2 to transform a subquery into a join . . . . . . . . . 716<br />

Subquery tuning . . . . . . . . . . . . . . . . . . . . . . . 717<br />

Using scrollable cursors efficiently . . . . . . . . . . . . . . . . . 718<br />

Writing efficient queries on tables with data-partitioned secondary indexes 719<br />

Special techniques to influence access path selection . . . . . . . . . . 721<br />

Obtaining information about access paths . . . . . . . . . . . . . 722<br />

Fetching a limited number of rows: FETCH FIRST n ROWS ONLY . . . . 722<br />

Minimizing overhead for retrieving few rows: OPTIMIZE FOR n ROWS 723<br />

Favoring index access . . . . . . . . . . . . . . . . . . . . . 725<br />

Using the CARDINALITY clause to improve the performance of queries with<br />

user-defined table function references . . . . . . . . . . . . . . 725<br />

Reducing the number of matching columns . . . . . . . . . . . . . 726<br />

Creating indexes for efficient star-join processing . . . . . . . . . . . 728<br />

Rearranging the order of tables in a FROM clause . . . . . . . . . . 731<br />

Updating catalog statistics . . . . . . . . . . . . . . . . . . . 731<br />

Using a subsystem parameter . . . . . . . . . . . . . . . . . . 732<br />

Chapter 27. Using EXPLAIN to improve <strong>SQL</strong> performance . . . . . . . 735<br />

Obtaining PLAN_TABLE information from EXPLAIN . . . . . . . . . . . 736<br />

Creating PLAN_TABLE . . . . . . . . . . . . . . . . . . . . 736<br />

Populating <strong>and</strong> maintaining a plan table . . . . . . . . . . . . . . 744<br />

Reordering rows from a plan table . . . . . . . . . . . . . . . . 745<br />

Asking questions about data access . . . . . . . . . . . . . . . . 746<br />

Is access through an index? (ACCESSTYPE is I, I1, N or MX) . . . . . . 746<br />

Is access through more than one index? (ACCESSTYPE=M) . . . . . . 747<br />

How many columns of the index are used in matching? (MATCHCOLS=n) 748<br />

Is the query satisfied using only the index? (INDEXONLY=Y) . . . . . . 748<br />

Is direct row access possible? (PRIMARY_ACCESSTYPE = D) . . . . . 749<br />

Is a view or nested table expression materialized? . . . . . . . . . . 752<br />

Was a scan limited to certain partitions? (PAGE_RANGE=Y) . . . . . . 752<br />

What kind of prefetching is expected? (PREFETCH = L, S, D, or blank) 753<br />

Is data accessed or processed in parallel? (PARALLELISM_MODE is I, C,<br />

or X) . . . . . . . . . . . . . . . . . . . . . . . . . . 753<br />

Are sorts performed? . . . . . . . . . . . . . . . . . . . . . 753<br />

Is a subquery transformed into a join? . . . . . . . . . . . . . . . 754<br />

When are aggregate functions evaluated? (COLUMN_FN_EVAL) . . . . . 754<br />

How many index screening columns are used? . . . . . . . . . . . 754<br />

Is a complex trigger WHEN clause used? (QBLOCKTYPE=TRIGGR) . . . 755<br />

Interpreting access to a single table . . . . . . . . . . . . . . . . . 755<br />

Table space scans (ACCESSTYPE=R PREFETCH=S) . . . . . . . . . 755<br />

Index access paths . . . . . . . . . . . . . . . . . . . . . . 756<br />

UPDATE using an index . . . . . . . . . . . . . . . . . . . . 761<br />

Interpreting access to two or more tables (join) . . . . . . . . . . . . 761<br />

Definitions <strong>and</strong> examples of join operations . . . . . . . . . . . . . 761<br />

Nested loop join (METHOD=1) . . . . . . . . . . . . . . . . . 764<br />

Merge scan join (METHOD=2) . . . . . . . . . . . . . . . . . . 766<br />

Hybrid join (METHOD=4) . . . . . . . . . . . . . . . . . . . . 767<br />

Contents xiii

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

Saved successfully!

Ooh no, something went wrong!