If a large list of posts may be updated/inserted, wrapping this in a db transaction would help performance.