Database Tuning: A Principled Approach