Skip to main content

write an efficient query

Efficient query writing it’s not a tough job. We are easily achieving it to following some point when writing a query. Here present some of them. I hope it's help you to writing efficient query.

write-efficient-query
write an efficient query
  1. Ensure proper joins for whatever tables in from clause.
  2. Avoid multiple table views.
  3. Instead of using the whole query in a single cursor or group, split into multiple Groups and link them.
  4. Use 'union all' instead of Union
  5. Use Union instead of OR Clause.
  6. Use Exists in place of in
  7. Always avoid usage of Negation operators like NOT, !=.
  8. Avoid Usage of outer joins , use Equi joins where ever possible 9. Use Where Clause instead of Having Clause.



-- Cheers !!!

Comments