Do db insertion in a transaction for speed