Use QueryOptimizer.optimize() in join query compilation