2. Tweaking Queries
• We can disable list prefetch using the OPTIMIZE
FOR 1 ROW clause
• SELECT EMPNO, WORKDEPT, EDLEVEL,
SALARY
FROM DSN81010.EMP
WHERE EMPNO BETWEEN '000020'
AND '000350'
AND (WORKDEPT > 'A01' OR 0 = 1);
This give option to DB2 to choose either Index or
Table space scan, but result will not be changed.
3. Tweaking Queries-Part-2
• OPTIMIZE FOR n ROWS: Note that the n can be
any value.
• FETCH FIRST n ROWS ONLY: Again, where n
can be any value.
• No Operation (+0, -
0, /1, *1, CONCAT ''): Adding or subtracting
zero, dividing or multiplying by 1, or
concatenating an empty string will not change
the results of a query but might change the
optimizer’s decision.
4. Best tuning methods
• Always keep update statistics in catalog tables
• Use appropriate columns in select
• Use indexes
• Always use where clause to filter data
5. Tuning in 3 phases
• System tuning
• Database tuning
• Application tuning
Reference here
6. Data Studio
• Data Studio is a free-of-charge tool for basic DB2
administration and development tasks. Data Studio
offers an easy to use GUI interface for the following:
• Designing data access queries and routines
• Building, running, and tuning SQL
• Building, testing, and deploying stored procedures
(using SQL or Java)
• Creating Web services in for Service Oriented
Architecture (SOA) solutions
• Developing DB2 SQLJ applications
• Managing database objects and authorizations