Steps to reproduce:
As admin, set enablegroupmembersonly to "Yes".
As teacher, in a course with many students
- create an assignment
- enable "Common module settings > Available for group members only" for the assignment
- On the course page click on the assignment (mod/assign/view.php)
- Notice how long it takes to load the page.
In an assignment with "Available for group members only" enabled, assignment view (mod/assign/view.php) takes a long time to load. We have a course with 180 students where the page takes more than 1 minute to load making one postgres process using 100% CPU.
In fact this makes things so slow it renders the assignment close to unusable, at least from the teacher's point of view. In addition the use of this feature has a considerable impact on the database server's workload.
Assignment view loads normally when "Available for group members only" is disabled.
I have attached an excerpt from our database log. It's the additional database queries the page generates per student when "Available for group members only" enabled.
This is probably caused by the call to groups_course_module_visible for each user introduced in http://git.moodle.org/gw?p=moodle.git;a=commit;h=a0e59f04dd422f494f326f5e6ddfcc3b5ae611b1
Our Moodle database is on PostgreSQL 8.4, but this bug probably affects other databases as well.