commit to CouchDB only when necessary