optimise source ref query