sql query optimization

Some queries in PostsController optimized to reduce query numbers and
cached index route