[ALOY-1081] improve query selection speed