This looks too crude, and I think it breaks when multiple raw_joins are presents and maybe in other cases. So maybe we need to make merge but with with index shift.