Move to db side other code. Improve performance of inserting posts