Writing Fast Queries
• Optimizer tips and tricks
– It’s smart, but not perfect
– Only one index per table per query
• You may need to de-normalize to get performance
• You may need to write two queries instead of one
– Don’t compute in the WHERE
• MySQL doesn’t know how to optimize constant
expressions
SELECT * FROM Headlines
WHERE Time > SUBDATE(NOW(), INTERVAL 7 DAY);
Copyright 2002, Jeremy Zawodny (Jeremy@Zawodny.com)