Speed up get_random_values for field

This uses the same technique as for speeding up get_search_values.