The following SQL checklist will help to review SQL Queries.
- Check for by mistake any inner join is coded as outer-join
- Check all union statements, is it really needed, or we can go with UNION ALL
- Check for NULLABLE columns, if NULL value comes, we need to handle -305 errors
- Check for Select statement, is all the columns absolutely needed
- Check for ALL aggregate functions, handling NULL values properly
- Check for DISTINCT statements. Always better either go with Sub-query or Co-related sub-query or Group by
- Check for each CASE statement ELSE is coded or not.
- Check for NOT logic. It works as non-index scan
Keep reading for more checklist in my next post.