SQL Best Practices
Tips about writing better SQL queries that optimized for performance.
- Only retrieve the field that you need.
- Limit your results.
- Avoid many tables join if you could.
- 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: