- port the _collect_insert_commands optimizations from ticket_3100