Minor efficiency improvements when inserting many values into the database.