Consideration
when writing an SQL statement is that it returns a correct result.
The second is that it be the most efficient for a given situation.
You can use many different SQL statements to achieve the same
result. It is often the case that only one statement will be the most
efficient choice in a given situation.
Remember
that processing SQL is a sequence of Parse (syntax check and object
resolution), Execution (required reads and writes), and Fetch (row
results retrieved, listed, sorted, and returned). SQL “tuning”
consists, quite simply, of reducing one or more of them.
Note:
generally Parse is the greatest time and resource hog. Parse overhead
can be minimized by the use of Procedures, Functions, Packages,
Views, etc.