Updated: Comment #153
Problem/Motivation
Drupal's current method of determining whether a specified user has access to a node is reported to have significant performance issues on a site using node access with a large number of grants.
Proposed resolution
A patch has been prepared, however it appears to be unclear as to what functionality/performance testing might be required or how it would be undertaken.
Remaining tasks
- (todo) commit patch #133
------------------------------------------------------------
Not sure if its faster, but I thought it might:
function node_access($op, $node = NULL) {
// ...
// If the module did not override the access rights, use those set in the
// node_access table.
if ($op != 'create'&& $node->nid && $node->status) {
$grants = array();
foreach (node_access_grants($op) as $realm => $gids) {
foreach ($gids as $gid) {
$grants[] = "(gid = $gid AND realm = '$realm')";
}
}
// ...
}
function node_access($op, $node = NULL) {
// ...
// If the module did not override the access rights, use those set in the
// node_access table.
if ($op != 'create'&& $node->nid && $node->status) {
$grants = array();
foreach (node_access_grants($op) as $realm => $gids) {
$grants[] = "((realm = '$realm') AND (gid = ".implode(' OR gid = ', $gids)."))";
}
// ...
}
Difference is that realm is just checked once; not per gid. But it is possible that mysql/postgre server already do this, I don't know.