Query Optimization in Dynamic Environments