Back to Tylogix Home Page
TYLOGIX SQL
Performance Page
Link to Tylogix SQL Page
Link to Tylogix SQL
Pivot Page
By Thibault Dambrine
Since I have started
posting SQL code, I have
noticed a number of requests for information on pivoting tables.
This is a first effort, consisting of both examples that I have created and
outside links.
The two techniques below are a starting point but once you get the concept, you can apply it to a
number of situations.
For variety, I have also included a number of outside links on the same topic.
SQL Performance Tips - Links within this page |
SQL Performance Tips - Outside Links |
Query Join Condition
Performance: Base Principles |
|
Tylogix - SQL Performance Tips and Techniques |
Query Join Condition Performance: Base Principles - Be aware of the instances where DB2 will not use an
index: - Avoid the use casting in a join Order your WHERE Clauses by putting the comparisons in
order of efficiency: |
Sub-Queries: Correlated vs. Non-Correlated Performance Rules Subquery Definition: Exception: |
Correlated Sub-Select
vs. Join Example This query will
do one sub-select scan per row in
the main table:
|
Correlated Sub-Select
vs. Exception Join Comparison This query will
do one sub-select scan per row in
the main table: This query can
be re-written to get the same results much faster |
Non-Correlated
Sub-Select vs. Join Comparison This query does
all the join work before doing the aggregation it is This query can
be re-written to get the same results much faster |
Performance Pitfall:
The Deadly Cascaded Joins Take a look at
the following example of the Proverbial "Forever Processing" Join: This query can
be re-written to get the same results much faster Step 2: Create
a new intermediate work file with a 2-way join ONLY with tables Step 3: Complete
the select, again using only a 2-way join, ONLY with tables |