SQL Query Review Check these 3 Points

SQL Query performance saves CPU time and cost. In terms of SQL-program review, you must consider these THREE POINTS.

3 Must Check Key Points

  • SQL performance Tuning
  • SQL Formatting
  • SQL aggregate functions

#1). Scalar Functions

For every AVG, MIN, MAX, or SUM statement, make sure the SQL is coded to handle a null value. This will eliminate any -305 SQL abends.

Note: Handle Null values diligently

#2). Order By statements

Just take a look you really need Order by statements. Check all Order By statements. Are they needed? Is there a supporting index for what is being ordered? Sometimes an ORDER BY can be efficient if it matches an index.

Note: Ensure Only index columns present in Order By

#3). Duplicates check

Check all Distinct statements. Can there definitely be duplicates? Can such a statement be coded with a Group By or rewritten as a correlated or non-correlated subquery?

In V9, the Distinct works just like the Group By statement in that DB2 will look for sort avoidance by checking for appropriate indexes.

Avoid possible duplicate retrieval areas

Also Read

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.