Optimization: combine lower and upper range queries into single range query.