fixes a performance problem in one SELECT