Our discourse overload because of a custom plugin. Please help me

My hunch is an index will help but won’t be enough. What this really needs is a fact table.

I implemented something similar but used a fact table and jobs to pre calc the results so it wasn’t causing load on page retrieve.