This looks like it is going to be very slow, do you think there is any advantage to just running INSERT/UPDATE operations on spaces_overrides table?