That’s fairly informative (although not on-topic for the problem
identified). Reading a few more of the articles by Richard To shows
there’s plenty of insight into how to optimize one’s code.
I didn’t notice anything along the lines of a “newbie’s
introduction into optimization” section. Specifically surrounding such
factors as “know your data”. Such articles would be quite beneficial
to those new at performance optimizing.
For example, the rules “know your data, know it’s use” are
still very much requirements for the developer working to optimize code.
In the article linked to – near the bottom – there’s a rewrite
that changes the “exists” to an “in” statement. The
results end up being a time improvement from 2:21 (minutes:seconds) to 0:07.5.
It’s actually a bad example for me to make my point with, but I’ll
Let’s say a report is run once a month using the original SQL and the
report commonly pulls 0.25% of the records in the total dataset. On the other
hand, daily reports are run with the same SQL that end up pulling > 75% of
the total dataset. In this scenario, rewriting the “exists” to an
“in” could actually end up being detrimental. The change could lead
to a performance improvement for the single monthly report while having the
opposite effect on the daily reports. The 2 minutes you saved on that one report
could amount to a cost of hours the rest of the month.
As Richard said in another of his articles: “ However, for something that
needs instinct or innovation, a machine definitely cannot replace humans at this
I would certainly recommend his articles for anyone interested in performance
with the caveat of keeping the basics in mind: