HHH-9455 : Unnecessary select count query in some cases