You are on page 1of 23

Mainframe

Performance Tuning
WORKSHOP

THIRDWARE TECHNOLOGY SOLUTIONS 1


Agenda (Day 3)

 DB2 - SQL Tuning – Continuation

 JCL/Job Flow Tuning

 Program Tuning

 Q &A

 Brainstorming Session

THIRDWARE TECHNOLOGY SOLUTIONS 2


Basic Tuning Concepts
SQL statement is submitted to the database
SELECT NAME, PHONE_NUMBER FROM RESTAURANTS
WHERE CITY = ‘IRVINE’ AND
FOOD_TYPE = ‘PIZZA’ AND
SERVICE = ‘DELIVERY’
ORDER BY NAME

DB engine creates a “plan” to process the SQL


The plan is generated by the DB engine optimizer, considering many variables
There are ways to make the optimizer make smarter decisions and … the SQL run faster

THIRDWARE TECHNOLOGY SOLUTIONS 3


… more Tuning Concepts
Understand the plan—not a trivial task

Change the plan to make things faster. How?


◦ Indexing: an index is like a table of contents, using one you can get quicker to the correct page
◦ Write the same SQL in a different way (re-write)
◦ Give the optimizer hints

THIRDWARE TECHNOLOGY SOLUTIONS 4


Database Application Lifecycle and solution
for tuning

Development Test Production

 Tune SQL while building Profile the way the  Identify slowdowns fast
the application application accesses the DB and fix them
(proactively) Analyze application  Analyze performance
 Development and tuning performance while proactively to identify
work hand-in-hand. simulating the production problems ahead of time
env.  Monitoring, diagnosis
Tuning, impact analysis and resolution
and profiling solutions.

THIRDWARE TECHNOLOGY SOLUTIONS 5


Optimization Process

2.
2.Rewrite
RewriteSQL
SQL

1.
1.Identify
Identify
Problematic 3. Benchmark SQL
ProblematicSQL
SQL
alternatives

Best SQL

THIRDWARE TECHNOLOGY SOLUTIONS 6


SQL Query Tuning – Some Check Points

 Never use SELECT *

 Singleton SELECT versus Cursor

 Use FOR FETCH ONLY

 Avoid using DISTINCT

THIRDWARE TECHNOLOGY SOLUTIONS 7


SQL Query Tuning – Some Check Points

 Limit the Data Selected

 Code Predicates on Indexed columns

 Multicolumn Indexes

 Use ORDER BY when the sequence is important

THIRDWARE TECHNOLOGY SOLUTIONS 8


SQL Query Tuning – Some Check Points

 Use Equivalent data types

 Use BETWEEN instead of <= and >=

 Use IN instead of LIKE

 Formulate LIKE predicates with care

THIRDWARE TECHNOLOGY SOLUTIONS 9


SQL Query Tuning – Some Check Points

 Avoid using NOT (Except with EXISTS)

 Code the most restrictive predicate first

 Be careful with Arithmetic precision

 Do not use arithmetic expressions in a predicate

THIRDWARE TECHNOLOGY SOLUTIONS 10


SQL Query Tuning – Some Check Points

 Specify number of rows to be returned

 Limit use of scalar functions

 UNION versus UNION ALL

THIRDWARE TECHNOLOGY SOLUTIONS 11


SQL Query Tuning – Some Check Points

 Use NOT EXISTS instead of NOT IN

 Minimize the number of tables in a join

 Join using SQL instead of program logic

THIRDWARE TECHNOLOGY SOLUTIONS 12


SQL Query Tuning – Some Check Points

 Use Joins instead of Subqueries

 Join on Clustered indexes

 Join on Indexed columns

 Avoid cartesian products

THIRDWARE TECHNOLOGY SOLUTIONS 13


SQL Query Tuning – Some Check Points

 Limit updating indexed columns

 Use FOR UPDATE OF correctly

 Consider using DELETE / INSERT instead of FOR UPDATE OF

THIRDWARE TECHNOLOGY SOLUTIONS 14


SQL Query Tuning – Some Check Points

 Updating Multiple rows

 UPDATE only changed columns

 Consider dropping indexes before large insertions

 List columns for INSERT

THIRDWARE TECHNOLOGY SOLUTIONS 15


SQL Query Tuning – Some Check Points

 List Columns for insert

 Update only Changed Columns

 Use NOT EXISTS instead of NOT IN

 Use Constants and Literals if the values will not change for the next 3 years (for static queries)

THIRDWARE TECHNOLOGY SOLUTIONS 16


SQL Query Tuning – Some Check Points

 SELECT COLA, COLB, COLC ORDER BY COLC

 Consider using DELETE / INSERT instead of FOR UPDATE OF

 Drop Unused Indexes

 Better to create Indexes on columns that have integer values instead of characters. Integer values use less
overhead than character values

 Use Joins instead of Subqueries or combining multiple Single SQLs

THIRDWARE TECHNOLOGY SOLUTIONS 17


SQL Query Tuning – Some Check Points
 JOINS

o Minimize number of tables in a Join

o Join using SQL instead of Program Logic

o Inner Joins preferred over Outer Joins, as applicable

o Avoid Cartesian products / Cross Joins

o JOINs on common indexed column or columns shared the Joined tables is preferred.

o Make sure to use the most restrictive JOIN table first; and provide as many indexed and restrictive
WHERE clauses as possible to limit the amount of data that needs to be Joined to the second or
subsequent tables.

THIRDWARE TECHNOLOGY SOLUTIONS 18


Jobs/Job flow Revisit
 Split JCLs if applicable

 Eliminate redundant Processes/Jobs/Steps

 Revisit the utilities – e. g. Load/Unload

 If not for specific reason, code BLKSIZE=0* or leave without coding it

 For larger files, go for TAPE rather than DASD

 Suggest SPACE Parm** Calculation depending on usage (ex. In ERES)

 Use consistent HLQ

 Avoid Instream Data, rather use Parm lib/Control card

THIRDWARE TECHNOLOGY SOLUTIONS 19


COBOL Program/Logic Tuning

 Follow Structured Coding

 Adopt Top-Down Approach

 Replace possible “IF-ELSE” with “EVALUATE”

 Avoid Backward “GO-TO”s

 Indentation – Increase Readability (for new Programs)

 Avoid COBOL SORTING – Use JCL Sorting or Use FASTSRT Compiler Option

THIRDWARE TECHNOLOGY SOLUTIONS 20


COBOL Program/Logic Tuning continues…

 Avoid Rounding Numeric Values in intermediate stage, instead do at the end

 For Arithmetic, use “Signed” Numeric Fields

 For VB Sequential files, apply use “APPLY WRITE-ONLY”

 Replace “SEARCH” with “SEARCH ALL”

 Use Indices than Subscripts to access COBOL tables

 Loop Control Variables – use Binary data item

THIRDWARE TECHNOLOGY SOLUTIONS 21


Conclusion

Brainstorming and Q&A Session

THIRDWARE TECHNOLOGY SOLUTIONS 22


Thank You

THIRDWARE TECHNOLOGY SOLUTIONS 23

You might also like