Affects Version/s: 2.0.2 CE GA1, 2.0.3 EE
The code in 'so-portlet/view_invite.jsp' is not optimal when there's a large (5k+) number of users in database.
I've tried to test and profile a simple scenario:
1. have at least 5k users in portal database;
2. go to some Social Office site;
3. go to members page in this site;
4. click on button 'Invite members to this site'.
If you have empty portal caches for users and groups, you can wait up to tens of seconds (30-40 for our case of 5k+ users) before the popup is rendered. This is caused by ineffective code in so-portlet -> view_invite.jsp. Based on profiling, most of the time is spent on DB calls. The JSP needs to display all non-members of selected group. Current code:
1. fetches all users of given company (using UserLocalServiceImpl.search(), which after retrieving all company's userIds fetches the User objects one by one) and
2. then one by one calls UserLocalServiceUtil.hasGroupUser(layout.getGroupId(), curUser.getUserId()) and if user is not a member, adds him to new list;
3. then iterates through newly constructed list – through group's non-members – and renders HTML table
So we could end up with more than 10k DB queries for a single JSP rendering (for the first pop-up displaying, then the query results are cached for 10 minutes).
We should change the JSP code to use more suitable service calls in a such way that the time needed to render the popup is reasonable even for large users' databases.