Optimize joins in queries.