Use a subquery to improve the query performance.
Use a subquery to improve the query performance.

An annotate with Count on a many-to-many was making an extra
join that was degrading the performance.

Replaced this with a subquery and the performance is acceptable now.

EBI-Metagenomics/emgapi,EBI-Metagenomics/emgapi,EBI-Metagenomics/emgapi,EBI-Metagenomics/emgapi,EBI-Metagenomics/emgapi