This would probably be better actually as a batch.  IIRC, you should be able to call prepareBatch() on the handle, iterate over the segments adding their bindings and then call executeBatch() to have it all run together.  Batches aren't actually committed transactionally unless you put them in a transaction, but it does decrease the amount of interaction you have to do with the DB, which can be a good thing.