SQL Best Practices

Tips about writing better SQL queries that optimized for performance.

  1. Only retrieve the field that you need.
  2. Limit your results.
  3. Avoid many tables join if you could.
  4. Avoid ordering, grouping, and distinct if you could.

The most importantly, keep your queries simple. Keep the best practices of using the syntax or function. Some problems may have different complexity. So, you need to concern about performance, always. You could use not exists instead of not in when comparing nullable columns such as an example.

Here are the references for SQL syntaxes and functions:


comments powered by Disqus