It is rearlly odd, we were seeing problems on some courses, on some Moodle sites, but not others.
I am taking about the page you get to by, for example, going into a Forum in a Course, and clicking Forum administration -> Locally assigned roles. For us, sometimes that page would never load, and just time out, because the database query was just running forever.
(However, the first few times we investigated, the probably only happened on the live servers. On a copy of the database on a test server, the query ran fast.)
I did just reproduce the problem on a test server, and I think I have a fix: MDL-47426.
However, that fix works for me on one example course, on our database (which is Postgres). Before this could be integrated, we really need to know that it is an improvement on other courses, and with other database servers.
So, if anyone else is having performance problems on that page, please could you try my patch, and report back on whether it is an improvement or not. Thank you.