You are inserting the first 3 gmvs with result_grp_ordinal=1, the rest with result_grp_ordinal=2. I would rather insert the full array twice, one with grp_ordinal=1 and one with grp_ordinal=2, than having gmvs with non-homogenous length.