SQL write Query with Tuning tips

Query Performance Tuning
====================

 In this post i will give few tips while writing sql query, how we can write better query with less cost
 If you follow below steps keep in mind while writing query you can tune up your sql while writning
 time. Below are some tips which can be used as guideline.

  Make sure am not expert, But what i learn have been post here to help some one. 
  If you know more points or you want to add on more please post in comment session it help to me and also others to learn. 
  Even though i can miss some silly points or known point as well. 
  so please help to remind them !!!


  1. DISTINCT:-  Do not use, If the objective can be achieved otherwise. DISTINCT incurs an extra sort operation and therefore slows your queries down.  
  2. Indexed columns:- Do not modify indexed columns with functions like RTRIM, TO_CHAR, UPPER, TRUNC, As this will prevent the optimizer from identifying the index. If possible perform the modification on the constant side of the condition. If the indexed column is usually accessed through a function, consider creating a function based index. (many cases people use and functions and complain my query not using index).
  3. UNION:- Do not use UNION, if the objective can be achieved through an UNION ALL. UNION incurs an extra sort operation which can be avoided.
  4. EXISTS :- use if selective predicate in parent query .
  5. IN : use if selective predicate is in the sub query.
  6. joins from one complex view to another not recommended.
  7. Do not use HINTS (as oracle new version using CBO(cost based optimizer).
  8. statistics for the objects used in the query are up to date or not, need to check.
  9. Read explain plan and try  tune your query.
  10. Commented lines are not good in between query lines.
  11. Instead of using NULL some cases DECODE better to use.



still have more point will add on later .

Thanks for your visit, please help to post in comment session if you have more points or any correction from my statements. it help to me &others!!!

Comments

Popular posts from this blog

Shareplex some commands

SQL Tuning Task Creation ORA-13780: SQL statement does not exist.

ORA 700 [kskvmstatact: excessive swapping observed]