performance with counts
authorAlan Knowles <alan@roojs.com>
Thu, 26 Nov 2020 02:16:44 +0000 (10:16 +0800)
committerAlan Knowles <alan@roojs.com>
Thu, 26 Nov 2020 02:16:44 +0000 (10:16 +0800)
Pman.php
Pman/Roo.php

index 06b707e..abef5f9 100644 (file)
--- a/Pman.php
+++ b/Pman.php
@@ -755,9 +755,11 @@ class Pman extends HTML_FlexyFramework_Page
        
         
         $mods = $this->modulesList();
-        
+        $is_bootstrap = in_array('BAdmin', $mods);
+
         $this->callModules('applyCSSIncludes', $this);
         foreach($this->css_includes as $module => $ar) {
+            
             if ($ar) {
                 $this->assetArrayToHtml( $ar , 'css');
             }
@@ -768,6 +770,10 @@ class Pman extends HTML_FlexyFramework_Page
         
         foreach($mods as $mod) {
             // add the css file..
+            if ($is_bootstrap  && !file_exists($this->rootDir."/Pman/$mod/is_bootstrap")) {
+                echo '<!-- missing '. $this->rootDir."/Pman/$mod/is_bootstrap  - skipping -->";
+                continue;
+            }
             $this->outputCSSDir("Pman/$mod","*.css");
         }
         
index 3cccb1a..a173d24 100644 (file)
@@ -243,12 +243,11 @@ class Pman_Roo extends Pman
        
         // sets map and countWhat
         $this->loadMap($x, array(
-                    'columns' => $_columns,
-                    'distinct' => empty($_REQUEST['_distinct']) ? false:  $_REQUEST['_distinct'],
-                    'exclude' => empty($_REQUEST['_exclude_columns']) ? false:  explode(',', $_REQUEST['_exclude_columns'])
-            ));
-        
-        
+            'columns' => $_columns,
+            'distinct' => empty($_REQUEST['_distinct']) ? false:  $_REQUEST['_distinct'],
+            'exclude' => empty($_REQUEST['_exclude_columns']) ? false:  explode(',', $_REQUEST['_exclude_columns'])
+        ));
+         
         $this->setFilters($x,$_REQUEST);
         
         if (!$this->checkPerm($x,'S', $_REQUEST))  {
@@ -258,8 +257,13 @@ class Pman_Roo extends Pman
          //print_r($x);
         // build join if req.
           //DB_DataObject::debugLevel(1);
-       //   var_dump($this->countWhat);
-        $total = $x->count($this->countWhat);
+        // count with multiple joins and no conditions can be quite slow - so if there are no conditions - just remove the joins from the count.
+        $xx = clone($x);
+        if (empty($xx->_query['condition']) && !empty($xx->_join)) {
+            $xx->_join = '';
+        }
+       
+        $total = $xx->count($this->countWhat);
         // sorting..
       //   
         //var_dump($total);exit;