OAK-1561 optimised the iterations for BETWEEN queries