Query optimization in relational databases