Too many sql queries...

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
Jokkeri
New Member
New Member
Posts: 2
Joined: Wed Oct 06, 2010 10:58 am

Too many sql queries...

Post by Jokkeri »

Hello,

We have problem with sql queries. If we create new page and click the submit-button we get about 10 000 sql queries. Our pages are totally stuck because of that. Is there some solution to avoid this problem. Is this some kind of bug in CMS Made Simple? We currently have version 1.8.2 installed.

Installed modules are:
CGExtensions 1.19.6 Has Dependents (SiteMapMadeSimple)
CGSimpleSmarty 1.4.5
CMSMailer         2.0 Has Dependents (FormBuilder)
FileManager         1.0.2
FormBuilder         0.6b2
MenuManager 1.6.5
ModuleManager 1.4
MysqlDump         1.2.4
News         2.10.6
nuSOAP 1.0.2
Printing         1.1.0
Search 1.6.5
SiteMapMadeSimple 1.2.1
ThemeManager 1.1.1
TinyMCE 2.7.2

Best Regards
Jokkeri
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: Too many sql queries...

Post by RonnyK »

How many pages are in the system?
Is there 'extra' logic in the page-templates?
Are you using UDTs for additional logic?

Ronny
Jokkeri
New Member
New Member
Posts: 2
Joined: Wed Oct 06, 2010 10:58 am

Re: Too many sql queries...

Post by Jokkeri »

We have 2156 pages in our system currently.

We have two types of pages. Categories and Products.
In the template of products we have an additional price content block.

In the template of Category page we have this UDT to list the products:

Code: Select all

global $gCms;

$manager =& $gCms->GetHierarchyManager();
$thisPage = $gCms->variables['page_name'];
$currentNode = &$manager->sureGetNodeByAlias($thisPage);

$nodes = $currentNode->getChildren();

if ($currentNode->hasChildren()) {
echo '<table border="0">';
echo '<tr>';
echo '<td>Product</td>';
echo '<td class="row4">Price €</td>';
echo '<td class="row3"></td>';
echo '</tr>';

  foreach ($nodes as $node) {
     $content= $node->getContent();
if(isset($content)){
       if ($content->Active()){

$page_alias = $content->Alias();
$cgsimple = $smarty->get_template_vars('cgsimple');
$Price = $cgsimple->get_page_content($page_alias, 'Price');

     $url = $content->GetURL();
    if ($url == "#") { /* section header has no link by default */
      $url = "index.php?page=".$content->Alias();
    }
echo '<tr>';
    echo "<td class=\"row1\">".$content->MenuText()."</td>";
    echo "<td class=\"row2\">".$Price."</td>";
    echo "<td class=\"row3\"><a href=\"".$url."\">More info »</a></td>";
echo '</tr>';
   }}
  }
echo '</table>';
}
And in the template of  product page we have this UDT to list the related products and to create link back to the category page:

Code: Select all

global $gCms;

// get current page
$manager =& $gCms->GetHierarchyManager();
$thisPage = $gCms->variables['page_name'];

//get current page parent
$currentNode = & $manager->sureGetNodeByAlias($thisPage);
$parentNode = $currentNode->getParent();

if ($parentNode->hasChildren())
{
   $sibblings = $parentNode->getChildren();
   $numPages = count($sibblings);   
   
   //max items to show
   $max = 10;

if($numPages > 1)
{
echo '<p><strong>Related products:</strong></p>';
}
echo '<p>';

   for ($i=0; $i<$numPages; $i++)
   {
       $page = $sibblings[$i];
       $content = $page->getContent();
       //Dont show inactive pages
       if( isset($content))
      {
       if ($content->Active())
      {
       $alias = $content->Alias();
       $text = $content->menutext();
       $url = $content->GetURL();
       if ($thisPage == $alias)
       {
       //Dont show current page
       }
       else
      {
          echo "<a href=\"".$url."\">".$text."</a><br /> ";
          $max--;
          if($max==0)
          {
          $i = $numPages;
          }

       }
     }
    }
    }
echo '</p>';
}
$Pcontent = $parentNode->getContent();
$Ptext = $Pcontent->menutext();
$Purl = $Pcontent->GetURL();
echo '<p>';
echo "<br /><a href='".$Purl."'>Return to ".$Ptext." >></a>";
echo '</p>';
-Jokkeri
NaN

Re: Too many sql queries...

Post by NaN »

Smarty logic or UDTs in template or content should not cause additional sql queries if you save a page in backend. Template or content is not processed on saving pages.

The problem could be the search module that tries to reindex all pages (for whatever reason). Try if anything changes with disabled search module.

Do you have additional UDTs that are subscribed to the EventManager and listen to the event ContentEditPost (besides the search module)?
Post Reply

Return to “CMSMS Core”