Fix to avoid expensive hashCode() computation for 2nd order queries