More Guidelines for Query Tuning
Minimize the use of DISTINCT: don’t need it if duplicates are acceptable, or if answer contains a key.
Minimize the use of GROUP BY and HAVING:
- Consider DBMS use of index when writing arithmetic expressions: E.age=2*D.age will benefit from index on E.age, but might not benefit from index on D.age!