Speed up bulk edit for foreign keys