Optimizing Mail.app index
Some while ago someone posted an AppleScript to optimize the Mail.app index. I prefer bash over AppleScript. So I just dump my version here:
killall Mail
BEFORE=`ls -lah ~/Library/Mail | grep -E 'Envelope Index$' | awk '{ print $5 }'`
sqlite3 ~/Library/Mail/'Envelope Index' vacuum
AFTER=`ls -lah ~/Library/Mail | grep -E 'Envelope Index$' | awk '{ print $5}'`
echo "before: $BEFORE"
echo "after: $AFTER"
For more details see this blog post or hawk wings.


