Optimize path queries by use subquery on locations_posts instead of expensive join.