Only begin a transaction when there's something to commit