Refactoring SQL query for most recent posts.