We are having performance issues with group assignments grading, view all submissions - view. With normal assignments the loading times for the view all submissions is few seconds, with group assignments this pumps up to 20 to seconds. We looked into this and it seems that the view uses a query that takes 682ms to plan and 0.351ms to execute in PostgreSql, but it runs the query 30 times to create the view -> 30 X 0.6seconds = 18seconds.
We do realize that part of the problem is the amount of groups & group members in our system
avle=# select count from mdl_groups; count ------- 30662 (1 row)
avle=# select count from mdl_groups_members; count -------- 302825 (1 row)
but this behavior is making the view all - view unusable.
Our environment is load-balanced 6 nodes (VM) with hardware DB (PostgreSql 9.4).
I am attaching the Explain Analyze Query into this message.