Optimize to use batch inserts instead of single row insert