Skip to content

RecalculateSharingRules() is incredibly slow

When you have a large system with a hundred or more users this function takes ages to run (can be 30 minutes or more). During a migration it gets called numerous times causing the migration process to be unnecessarily slow.

Could I make few suggestions:

  • That this function only runs on "Active" users. Currently the database query ignores this parameter:
http://code.vtiger.com/vtiger/vtigercrm/blob/master/include/utils/UserInfoUtil.php#L2197

i.e. $query="select id from vtiger_users where deleted=0 AND status = 'Active'";

  • When a user is "reactivated" perhaps a subset of this function could be called with JUST the ID of the user being reactivated?

  • Some sort of flag is built into the migration and/or vtlib code (Access.php calls it) so this function is only called ONCE at the end of a migration script?