Let me start by saying, this certainly isn't a complaint about nodeaccess_nodereference. I've just been doing some reading about the node grants system and thought this stuff may be of interest.
I built a site which made heavy use of nodeaccess_nodereference and nodeaccess_userreference, but it got to the stage where there was a massive performance hit on every node view, because of the large number of nodes in the database and the complex relationships I had set up between content types (around 7 node reference fields and 3 user reference fields). As a result, I've had to disable nodeaccess_nodereference and relax the access control employed on the site (hopefully not a problem since the site was for internal use and the users are all colleagues of mine).
Subsequently, while reading this issue: #1186320: Get rid of the node grant system, I saw this proof-of-concept module linked to: http://drupal.org/project/nodetype_access and wondered if the same techniques could be used to greatly reduce the overhead in nodeaccess_nodereference by avoiding the node grants system.
It seems to do all the access checks using hook_node_access(), which is obviously aware of the individual node being checked because it takes the node object as one of its arguments. It then handles node listings by implementing query alteration. As a result, calls to hook_node_grants() are avoided but it remains fully funtional with views, etc.
Unless I'm missing something, it seems like this technique could provide massive optimisations for nodeaccess_nodereference. Maybe something to look at for a 2.x branch?
I might see if I can get my head round it myself at some point.
Comments
Comment #1
masipila commentedHi,
I noticed a significant performance penalty on my site which I was able to pinpoint to this module. I'm not complaining but more writing this as a reference for others googling for Drupal 7 ACL / access control related performance problems.
My setup was as follows:
1. I have content types team and league
2. Team has a nodereference to league
3. I had configured so that if user has update permission to league, she also gets update permission to teams that are referencing to the league.
I have hundreds of leagues and thousands of teams. The total number of nodes is more than 10k.
What I observed was that I got significant performance penalty for all page loads for authenticated users. When I disabled nodeaccess nodereference, the page load times improved significantly.
I started to suspect that the performance issue was related to access control because the site worked quite well for user 1 / administrator but it was significantly slower for other autenticated users. This is probably because Drupal access checks always return TRUE for user 1.
Cheers,
Markus
Comment #2
danielb commentedI like this idea. I seem to recall hook_node_access had a shortcoming in some scenario where it just wouldn't kick in. That may have changed.
This module was designed prior to hook_node_access existing.
Comment #3
anybodyI can confirm this problem even for user 0. As user 1 the speed is perfect, but for other users the speed is very low and giant SQL statements are being created containging thousands of ORs for nodeaccess_nodereference_view...
Comment #4
anybodyYes this module surely is the reason for performance problems on large sites. With an anonymous user the page load was reduced from 8 seconds to 0.5 when disabling this module. Furthermore the complex grants queries are not needed in many cases for example on nodes which everyone may view.
Comment #5
anybodyI finally developed https://www.drupal.org/project/content_access_booster to fix these problems. The same generic logic using hook_node_access could be used for settings like the "view" for all users.
I you use Node access node reference in combination with content_access then content_access_boost may fix your performance problems too because it hooks in before the complex grants checks.
Comment #6
mageshbcet1 commentedHi Anybody,
We are using node access node references module in our site. We are also facing performance issue for authenticated users in our site due to this module. Even we installed Content Access Booster (https://www.drupal.org/project/content_access_booster) module there is no improvement in performance. Do we need to configure any other settings? Please help!
Regards,
Magesh