Ensuring your website has adequate permissions to restrict the availability of content to particular users can be important, especially to websites with subscription-based content models or ones that have other reasons for differing levels of user permissions. When content is created, it may have one set of permissions for access, but as things change on your website, you may need to restrict or free some of this content. In order to ensure that only the correct users can access particular content, you may need to rebuild your node access permissions.
The standard method of rebuilding your permissions in Drupal 7 is to sign in to your website as an administrator, go to Reports > Status report, and then scroll down to the section labelled Node Access Permissions, where you will find a link to Rebuild permissions.
One of the biggest issues with rebuilding your node access is the amount of time the server has to spend rebuilding the table. On a large website, this can be severely performance impacting. If you do a straight rebuild of the permissions, your website may become unresponsive. Worse, the process that is rebuilding the permissions may time out before completing, leaving you with nodes that are incorrect. These will eventually correct themselves over time, but can lead to continuing issues with responsiveness.
There are, however, a few ways that we can accomplish a rebuild while maintaining website integrity to the best of our abilities.
Use a module
The Queued Node Access Rebuild module "uses Queue to rebuild node access in a non-disruptive manner." It depends on the
drupal_queue. This module can help you batch items to queue, and rebuild access in a timely fashion that doesn't kill your server.
Drush can help you solve this problem if you want to use the command line, rather than the user interface. This is especially useful when you're troubleshooting, or if you simply do not have access to the UI.
Drupal includes the node_access_rebuild function, which includes a variable to batch the requests. This helps prevent server overloading. You can use drush to call this function.
drush php-eval 'node_access_rebuild($batch_mode = TRUE) '
If you have a small website, you can call it without the
drush php-eval 'node_access_rebuild()'