I did a simple patch that reduces the number of SQL queries to 3 instead of 3 * N (where N is count($nodes)) in simple_access_node_load() implementation.

This is still way too many queries for each node_load() operation, but is still a lot better.

Comments

pounard’s picture

StatusFileSize
new3.64 KB
gordon’s picture

Status: Active » Needs work
+++ b/simple_access.module
@@ -162,28 +162,46 @@ function simple_access_node_prepare($node) {
@@ -382,7 +400,7 @@ function simple_access_form_node_type_form_alter(&$form, &$form_state) {

@@ -382,7 +400,7 @@ function simple_access_form_node_type_form_alter(&$form, &$form_state) {
 
   $tmp_form = simple_access_form((object)$default, TRUE);
 
-  $form['simple_access'] = $tmp_form['sa'];
+  $form['simple_access'] = $tmp_form['simple_access'];
   $form['simple_access']['simple_access']['owner']['#parents'] = array('simple_access', 'simple_access_owner');
   $form['simple_access']['#tree'] = TRUE;
 
@@ -632,11 +650,11 @@ function simple_access_group_select() {

@@ -632,11 +650,11 @@ function simple_access_group_select() {
     // return just groups for which user is a member
       $roles = array_keys($user->roles);
       $result = db_select('simple_access_groups', 'g')
-        ->fields('g', array('gid'))
-        ->innerJoin('simple_access_roles', 'r', 'g.gid = r.gid')
-        ->condition('rid', $roles, 'IN')
-        ->groupBy('gid')
-        ->execute();
+      ->fields('g', array('gid'));
+      $result->innerJoin('simple_access_roles', 'r', 'g.gid = r.gid');
+      $result->condition('rid', $roles, 'IN');
+      $result->groupBy('gid');
+      $result = $result->execute();
       while ($group = $result->fetchAssoc(PDO::FETCH_ASSOC)) {
         $groups[$group['gid']]['access'] = TRUE;
       }
@@ -1071,4 +1089,4 @@ function simple_access_group_load($gid) {

@@ -1071,4 +1089,4 @@ function simple_access_group_load($gid) {
 
 function simple_access_profile_load($pid) {
   return simple_access_get_profiles($pid);
-}
\ No newline at end of file

Not apart of this content performance changes

pounard’s picture

Oups it seems another patch went into mine. Only the hook_node_load() part is revelant. I will redo it.

simon georges’s picture

Status: Needs work » Needs review
StatusFileSize
new2.49 KB

Patch with only node_load() modification. All credit goes to pounard.

gordon’s picture

This is looking good. 1 very small issue.

+++ b/simple_access.module
@@ -162,28 +162,44 @@ function simple_access_node_prepare($node) {
+  $nidList = array();

I don't use camel case in the code.

Thanks
Gordon.

simon georges’s picture

StatusFileSize
new2.5 KB

New attempt.

gordon’s picture

Thanks this has been committed to dev.

gordon’s picture

Status: Needs review » Fixed
pounard’s picture

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit a0ff98e on 7.x-2.x, 8.x-3.x by gordon:
    Issue #1916316 by Simon Georges, pounard: Performance and hook_node_load...