MDL-24419 (2): Moved groupings cache to get_all_groupings function