Automatically batch insert queries