I avoid correlated subqueries (uncorrelated subqueries and views are ok) and any cursors I can avoid. Also avoid when you can make loops. Think of datasets, not string processing.
If you use UNION, check if UNION ALL will work. There is a potential difference in results, so be sure to make changes before making any changes.
I always look at the word DISTINCT as a hint to see if there is a better way to present the data. DISTINCT is expensive compared to using a view or some other way to avoid using it.
Avoid the syntax of the implied connection to avoid accidental cross-connection (which people often fix, shudder, with crisp). (Creating a list of 4 million records, and then making differences to get the three you want, is expensive.)
Avoid views that trigger other views! We have people who designed a whole customer database in this way, and the performance is AWESOME! Do not go down this path.
Avoid syntax like WHERE MyField Like "% test%"
These are other irrelevant arguments that the optimizer may contain from using indexes.
Hlgem source share