Terrible slow query with relationship (REST API)

System Information
  • Strapi Version: 3.6.2
  • Operating System:
  • Database: MongoDB
  • Node Version: 14.xx
  • NPM Version: 6.x
  • Yarn Version:

My backend have about 6000 posts. Every post has tags. There are more than 4000 tags now.
I write a simple query to count posts with specific tag. Example: https://example.com/posts/count?tag.slug=xxx
Every request will take about 40s to complete! I already installed strapi-middleware-cache.
So how can I fix them? Thanks.