Semantic Query Optimization: Correctness and Control