in reply to (OT) Improving a SQL JOIN statement

Looking at the SQL, it looks like MySQL. But if it is or isn't there are somethings that are important to consider. Databases such as Oracle perform "WHERE" clauses from reverse. Often in my attempts to limit the number of records I would put the most limiting first and the most painful last. This was wrong (actually, under newer versions of Oracle, I think it may not matter as their optimizer takes care of this). The other thing to becareful of is to not do anything in your where clause that manipulates a column which is indexed (such as using like, translating a date, or adding numbers). This will prevent it from using the index. Lastly, do you need to do the "ORDER BY". The database can begin handing back results as soon as it finds one if you haven't done an "ORDER BY". These are all small things (well sometimes they are huge), but they can add up to poor performance.
  • Comment on Re: (OT) Improving a SQL JOIN statement