Jump to content


Corporate Sponsors


Latest News: (loading..)

* * * * * 5 votes

A Store Speed Optimization in Progress


897 replies to this topic

#761 discxpress

  • Community Member
  • 286 posts
  • Real Name:Lecarl Butler
  • Gender:Male

Posted 22 November 2009, 15:20

View PostFWR Media, on 22 November 2009, 14:19, said:

Looking at that one horrific query try the following in phpMyAdmin and see if it has an effect.

ALTER TABLE `specials` ADD UNIQUE `idx_s_products_id` ( `products_id` );

When I added this to my site it reduced that query (time) by some 70%

Also and very importantly ..

When was the last time you ran optimize and analyze on this database?
Rob,
I tried what you suggested, it actually increased the time by 70%. However, I've narrowed down the two queries I posted at the bottom of post #762 in this thread. [16] is in the Header Tags SEO V.3.1.8. The query is called in the 'Silo Box'(headertags_seo_silo.php). So, I can easily remove it from includes/column_left.php. As for [286], it's in includes/modules/new_products.php. Can the code be optimized for that one?

Quote

When was the last time you ran optimize and analyze on this database?
I did this 2 days ago in phpMyAdmin when I saw the suggestion in this thread. Everything checked out OK.

Thanks.

#762 tobybailey

  • Community Member
  • 33 posts
  • Real Name:Toby Bailey

Posted 22 November 2009, 21:46

I have just been dealing with a severe slow page load problem (sometimes 5-10 secs) in my store. While this thread started with the excellent aim of reducing the numbers of database queries, in fact the vast majority of those were taking a few milliseconds and were not remotely a problem for our one fair-sized store on a dedicated server.

The real issue was a handful of queries taking a hundred times longer than the rest. They turned out to be fixable by adding indices:

index products_id and orders_id on table orders_products (big improvement that speeds up the "products also ordered" box on our store by a factor of close to 100 - this table on our shop currently has 140000 rows);

index products_id on table special (as mentioned recently on this thread);

index manufacturers_id on table products.

Also the admin was speeded up (but not as much as I would like) by indexing orders_id on table orders_status_history. I suspect there's a query used in generating the usual default page of recent orders that also needs an added index somewhere when you have 50000 oders - anyone got an idea what it is? (Order date is already indexed.)

Anyway, the lesson I learnt was that in our situation at least the trick is not to worry about a lot of fine tuning, but instead install "Output debug queries" on a trial version of the site and isolate the very few points that are really the issue.

I'm not sure why these indices are not there by default - or perhaps they are and I have an outdated osCommerce installation.

Toby

#763 FWR Media

  • Community Member
  • 6,462 posts
  • Real Name:Robert Fisher
  • Gender:Male
  • Location:Stowmarket - Suffolk - UK

Posted 22 November 2009, 22:00

View Posttobybailey, on 22 November 2009, 21:46, said:

I have just been dealing with a severe slow page load problem (sometimes 5-10 secs) in my store. While this thread started with the excellent aim of reducing the numbers of database queries, in fact the vast majority of those were taking a few milliseconds and were not remotely a problem for our one fair-sized store on a dedicated server.

The real issue was a handful of queries taking a hundred times longer than the rest. They turned out to be fixable by adding indices:

index products_id and orders_id on table orders_products (big improvement that speeds up the "products also ordered" box on our store by a factor of close to 100 - this table on our shop currently has 140000 rows);

index products_id on table special (as mentioned recently on this thread);

index manufacturers_id on table products.

Also the admin was speeded up (but not as much as I would like) by indexing orders_id on table orders_status_history. I suspect there's a query used in generating the usual default page of recent orders that also needs an added index somewhere when you have 50000 oders - anyone got an idea what it is? (Order date is already indexed.)

Anyway, the lesson I learnt was that in our situation at least the trick is not to worry about a lot of fine tuning, but instead install "Output debug queries" on a trial version of the site and isolate the very few points that are really the issue.

I'm not sure why these indices are not there by default - or perhaps they are and I have an outdated osCommerce installation.

Toby

Indices are added in the Rc1/RC2a package but they also are not the holy grail. Indices especially on large tables take up a huge amount of space and can actually significantly slow things down if used indiscriminately.

Equally it only takes one mod and one more badly written query to require yet more indices .. a lot of shops use a lot of badly written contributions that work on the surface but create huge efficency problems.
Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls

KissMT Dynamic SEO Meta & Canonical Header Tags

KissER Error Handling and Debugging

If you found my post useful please click the green + sign to the right

Please only PM me for paid work.


#764 Jan Zonjee

  • Team Member
  • 6,975 posts
  • Real Name:Jan Zonjee
  • Gender:Male
  • Location:the Netherlands

Posted 22 November 2009, 22:00

View Postdiscxpress, on 22 November 2009, 15:20, said:

As for [286], it's in includes/modules/new_products.php. Can the code be optimized for that one?
Yes.
<?php
/*
  $Id: new_products.php #### 2008-01-11 00:52:16Z hpdl $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/
?>
<!-- new_products //-->
<?php
  $info_box_contents = array();
  $info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')));
  global $languages_id;

  new contentBoxHeading($info_box_contents);

  if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
    $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
  } else {
    $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
  }

  $row = 0;
  $col = 0;
  $info_box_contents = array();
  while ($_new_products = tep_db_fetch_array($new_products_query)) {
    $new_products[] = $_new_products;
    $products_id_array[] = $_new_products['products_id'];
  }
  if ($new_products_with_name = tep_add_product_names($products_id_array, $new_products)) {
    $new_products = $new_products_with_name;
    unset($new_products_with_name);
  }
//    $new_products['products_name'] = tep_get_products_name($new_products['products_id']);
  $no_of_new_products = count($new_products);
  for ($x = 0; $x < $no_of_new_products; $x++) { 
    $info_box_contents[$row][$col] = array('align' => 'center',
                                           'params' => 'class="smallText" width="33%" valign="top"',
                                           'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products[$x]['products_image'], $new_products[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products[$x]['products_id']) . '">' . $new_products[$x]['products_name'] . '</a><br>' . $currencies->display_price($new_products[$x]['products_price'], tep_get_tax_rate($new_products[$x]['products_tax_class_id'])));

    $col ++;
    if ($col > 2) {
      $col = 0;
      $row ++;
    }
  }

  new contentBox($info_box_contents);
?>
<!-- new_products_eof //-->
<?php
function tep_add_product_names ($products_id_array, $query_result_array) {
  global $languages_id;
  
  if (!is_array($products_id_array) || !is_array($query_result_array)) {
   return false;
  }
  foreach ($products_id_array as $key => $products_id) {
    $products_id_array[$key] = tep_get_prid($products_id);
  }
  $products_id_array = array_unique($products_id_array);
  
  $product_names_query = tep_db_query("select products_id, products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id in (" . implode(',', $products_id_array) . ") and language_id = '" . (int)$languages_id . "'");
  while ($_product_names = tep_db_fetch_array($product_names_query)) { 
   $product_names[] = array('products_id' => $_product_names['products_id'], 'products_name' => $_product_names['products_name']);  
  }

  $no_of_products = count($query_result_array);
  $no_of_product_names = count($product_names);
  for ($x = 0; $x < $no_of_products; $x++) {
    if (!empty($product_names)) {
      for ($i = 0; $i < $no_of_product_names; $i++) {
        if ($query_result_array[$x]['products_id'] == $product_names[$i]['products_id']) {
          $query_result_array[$x]['products_name'] = $product_names[$i]['products_name'];
        }
      }    
    }
  } // end for ($x = 0; $x < $no_of_new_products; $x++)
  return $query_result_array;
}
?>
Regarding featured_products, you can use the same technique as used above.

With category pages (index.php) I once posted a solution using temporary tables but I think the last upgrade of the forum software totally mangled the code because a lot of the code necessary for that to work is missing. It was quite a bit of code actually.

In that code a refinement should be added because the module is also used in advanced_search_results.php where $random_name is not set.
So
$clean_up = tep_db_query("drop table if exists " . $random_name . "");
Should be:
  if (isset($random_name) && tep_not_null($random_name)) {
    $clean_up = tep_db_query("drop table if exists " . $random_name . "");
  }


#765 tobybailey

  • Community Member
  • 33 posts
  • Real Name:Toby Bailey

Posted 22 November 2009, 22:11

View PostFWR Media, on 22 November 2009, 22:00, said:

Indices are added in the Rc1/RC2a package but they also are not the holy grail. Indices especially on large tables take up a huge amount of space and can actually significantly slow things down if used indiscriminately.

Equally it only takes one mod and one more badly written query to require yet more indices .. a lot of shops use a lot of badly written contributions that work on the surface but create huge efficency problems.

My osCommerce (like most, I guess) has been messed around with, but the problem queries that were slowing my site to a crawl are in the base code I think. One is in the splitResults thing used to list the products in a category, the other is part of the standard also-bought module.

#766 FWR Media

  • Community Member
  • 6,462 posts
  • Real Name:Robert Fisher
  • Gender:Male
  • Location:Stowmarket - Suffolk - UK

Posted 22 November 2009, 22:15

View Posttobybailey, on 22 November 2009, 22:11, said:

My osCommerce (like most, I guess) has been messed around with, but the problem queries that were slowing my site to a crawl are in the base code I think. One is in the splitResults thing used to list the products in a category, the other is part of the standard also-bought module.

Problem queries in the base code are covered in this thread pretty well.
Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls

KissMT Dynamic SEO Meta & Canonical Header Tags

KissER Error Handling and Debugging

If you found my post useful please click the green + sign to the right

Please only PM me for paid work.


#767 discxpress

  • Community Member
  • 286 posts
  • Real Name:Lecarl Butler
  • Gender:Male

Posted 23 November 2009, 07:40

View PostJan Zonjee, on 22 November 2009, 22:00, said:

Yes.
<?php
/*
  $Id: new_products.php #### 2008-01-11 00:52:16Z hpdl $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/
?>
<!-- new_products //-->
<?php
  $info_box_contents = array();
  $info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')));
  global $languages_id;

  new contentBoxHeading($info_box_contents);

  if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
    $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
  } else {
    $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
  }

  $row = 0;
  $col = 0;
  $info_box_contents = array();
  while ($_new_products = tep_db_fetch_array($new_products_query)) {
    $new_products[] = $_new_products;
    $products_id_array[] = $_new_products['products_id'];
  }
  if ($new_products_with_name = tep_add_product_names($products_id_array, $new_products)) {
    $new_products = $new_products_with_name;
    unset($new_products_with_name);
  }
//    $new_products['products_name'] = tep_get_products_name($new_products['products_id']);
  $no_of_new_products = count($new_products);
  for ($x = 0; $x < $no_of_new_products; $x++) { 
    $info_box_contents[$row][$col] = array('align' => 'center',
                                           'params' => 'class="smallText" width="33%" valign="top"',
                                           'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products[$x]['products_image'], $new_products[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products[$x]['products_id']) . '">' . $new_products[$x]['products_name'] . '</a><br>' . $currencies->display_price($new_products[$x]['products_price'], tep_get_tax_rate($new_products[$x]['products_tax_class_id'])));

    $col ++;
    if ($col > 2) {
      $col = 0;
      $row ++;
    }
  }

  new contentBox($info_box_contents);
?>
<!-- new_products_eof //-->
<?php
function tep_add_product_names ($products_id_array, $query_result_array) {
  global $languages_id;
  
  if (!is_array($products_id_array) || !is_array($query_result_array)) {
   return false;
  }
  foreach ($products_id_array as $key => $products_id) {
    $products_id_array[$key] = tep_get_prid($products_id);
  }
  $products_id_array = array_unique($products_id_array);
  
  $product_names_query = tep_db_query("select products_id, products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id in (" . implode(',', $products_id_array) . ") and language_id = '" . (int)$languages_id . "'");
  while ($_product_names = tep_db_fetch_array($product_names_query)) { 
   $product_names[] = array('products_id' => $_product_names['products_id'], 'products_name' => $_product_names['products_name']);  
  }

  $no_of_products = count($query_result_array);
  $no_of_product_names = count($product_names);
  for ($x = 0; $x < $no_of_products; $x++) {
    if (!empty($product_names)) {
      for ($i = 0; $i < $no_of_product_names; $i++) {
        if ($query_result_array[$x]['products_id'] == $product_names[$i]['products_id']) {
          $query_result_array[$x]['products_name'] = $product_names[$i]['products_name'];
        }
      }    
    }
  } // end for ($x = 0; $x < $no_of_new_products; $x++)
  return $query_result_array;
}
?>
Regarding featured_products, you can use the same technique as used above.

With category pages (index.php) I once posted a solution using temporary tables but I think the last upgrade of the forum software totally mangled the code because a lot of the code necessary for that to work is missing. It was quite a bit of code actually.

In that code a refinement should be added because the module is also used in advanced_search_results.php where $random_name is not set.
So
$clean_up = tep_db_query("drop table if exists " . $random_name . "");
Should be:
  if (isset($random_name) && tep_not_null($random_name)) {
    $clean_up = tep_db_query("drop table if exists " . $random_name . "");
  }

WOW!!!! I applied both code edits and now my site is super fast. I'm not sure yet what to do with the random name stuff because I can't find it anywhere in my code. I operate on RC2 (sorry for waiting so late to mention), if that helps. Jan you're a genius. Maybe I can get the guy who coded the Silo Box in Header Tags SEO to look over the code to see if he can find ways to optimize that box. He's great also.

I don't think the code was mangled. Because it works. The code must lose formatting and structure inside the new codeboxes.
TIP: For anyone who's having trouble copying and pacing code from the forum posts, this may help you. Click on reply on the post that contains the code you need. Then highlight all the code between the code tags then Ctrl+C. You will be able to copy and paste all code keeping its formatting and structure.

Many, many thanks.

Edited by discxpress, 23 November 2009, 07:44.


#768 FWR Media

  • Community Member
  • 6,462 posts
  • Real Name:Robert Fisher
  • Gender:Male
  • Location:Stowmarket - Suffolk - UK

Posted 23 November 2009, 09:34

I think the following would be a more efficient query plus the addition of an index on products.products_status..
SELECT pd.products_head_title_tag, p.products_id
FROM products_to_categories p2c
INNER JOIN products_description pd ON pd.products_id = p2c.products_id
AND pd.language_id = 'XXX'
INNER JOIN products p ON p.products_id = p2c.products_id
AND p.products_status = '1'
WHERE p2c.categories_id = 'XXX'
ORDER BY p.products_ordered
LIMIT 6

Obviously the above query would have to be put into the php format with DEFINES for table names and XXX replaced with the relevant variables.
Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls

KissMT Dynamic SEO Meta & Canonical Header Tags

KissER Error Handling and Debugging

If you found my post useful please click the green + sign to the right

Please only PM me for paid work.


#769 FWR Media

  • Community Member
  • 6,462 posts
  • Real Name:Robert Fisher
  • Gender:Male
  • Location:Stowmarket - Suffolk - UK

Posted 23 November 2009, 10:17

Most importantly

In table products_to_categories

Drop the dual primary index of products_id
categories_id

Add them back in as just individual indexes

This had a major effect on a shop with 2500 products it reduced the searched rows from about 2000 to just 166

NOTE: with this and the query above you do not need an index on products_status

Edited by FWR Media, 23 November 2009, 10:25.

Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls

KissMT Dynamic SEO Meta & Canonical Header Tags

KissER Error Handling and Debugging

If you found my post useful please click the green + sign to the right

Please only PM me for paid work.


#770 discxpress

  • Community Member
  • 286 posts
  • Real Name:Lecarl Butler
  • Gender:Male

Posted 23 November 2009, 12:24

View PostFWR Media, on 23 November 2009, 09:34, said:

I think the following would be a more efficient query plus the addition of an index on products.products_status..
SELECT pd.products_head_title_tag, p.products_id
FROM products_to_categories p2c
INNER JOIN products_description pd ON pd.products_id = p2c.products_id
AND pd.language_id = 'XXX'
INNER JOIN products p ON p.products_id = p2c.products_id
AND p.products_status = '1'
WHERE p2c.categories_id = 'XXX'
ORDER BY p.products_ordered
LIMIT 6

Obviously the above query would have to be put into the php format with DEFINES for table names and XXX replaced with the relevant variables.
Thanks for the reply. Is the following the proper php format?

Quote

$products_query = tep_db_query("select pd.products_head_title_tag, p.products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c inner join products_description pd on pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' INNER JOIN products p ON p.products_id = p2c.products_id AND p.products_status = '1' WHERE p2c.categories_id = '" . (int)$catID . "' order by p.products_ordered Limit " . $silo['max_links']);
Thanks for your help.

#771 discxpress

  • Community Member
  • 286 posts
  • Real Name:Lecarl Butler
  • Gender:Male

Posted 23 November 2009, 12:40

View PostFWR Media, on 23 November 2009, 10:17, said:

Most importantly

In table products_to_categories

Drop the dual primary index of products_id
categories_id

Add them back in as just individual indexes

This had a major effect on a shop with 2500 products it reduced the searched rows from about 2000 to just 166

NOTE: with this and the query above you do not need an index on products_status
Thanks, Rob. I done the above however phpMyAdmin wouldn't allow me to assign either index as PRIMARY. Would that be OK?

#772 FWR Media

  • Community Member
  • 6,462 posts
  • Real Name:Robert Fisher
  • Gender:Male
  • Location:Stowmarket - Suffolk - UK

Posted 23 November 2009, 12:52

View Postdiscxpress, on 23 November 2009, 12:40, said:

Thanks, Rob. I done the above however phpMyAdmin wouldn't allow me to assign either index as PRIMARY. Would that be OK?

Yes they musn't be primary

Quote

Add them back in as just individual indexes

Just individual indexes
Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls

KissMT Dynamic SEO Meta & Canonical Header Tags

KissER Error Handling and Debugging

If you found my post useful please click the green + sign to the right

Please only PM me for paid work.


#773 FWR Media

  • Community Member
  • 6,462 posts
  • Real Name:Robert Fisher
  • Gender:Male
  • Location:Stowmarket - Suffolk - UK

Posted 23 November 2009, 12:56

View Postdiscxpress, on 23 November 2009, 12:24, said:

Thanks for the reply. Is the following the proper php format?

Thanks for your help.

The following is correct

$products_query = tep_db_query("
SELECT pd.products_head_title_tag, p.products_id FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c
INNER JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON pd.products_id = p2c.products_id
AND pd.language_id = '" . (int)$languages_id . "'
INNER JOIN " . TABLE_PRODUCTS . " p ON p.products_id = p2c.products_id
AND p.products_status = '1'
WHERE p2c.categories_id = '" . (int)$catID . "'
ORDER BY p.products_ordered
LIMIT " . $silo['max_links'] . "");

Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls

KissMT Dynamic SEO Meta & Canonical Header Tags

KissER Error Handling and Debugging

If you found my post useful please click the green + sign to the right

Please only PM me for paid work.


#774 FWR Media

  • Community Member
  • 6,462 posts
  • Real Name:Robert Fisher
  • Gender:Male
  • Location:Stowmarket - Suffolk - UK

Posted 23 November 2009, 13:29

Except just noticed that $silo['max_links'] is not type cast which is a security risk

Should be (int)$silo['max_links']
Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls

KissMT Dynamic SEO Meta & Canonical Header Tags

KissER Error Handling and Debugging

If you found my post useful please click the green + sign to the right

Please only PM me for paid work.


#775 discxpress

  • Community Member
  • 286 posts
  • Real Name:Lecarl Butler
  • Gender:Male

Posted 23 November 2009, 14:17

View PostFWR Media, on 23 November 2009, 13:29, said:

Except just noticed that $silo['max_links'] is not type cast which is a security risk

Should be (int)$silo['max_links']
Thanks. It works out just fine. It loads fast. With the code you suggested the page loads Current Parse Time: 0.835 s with 367 queries compared to 20.176s with 367 queries.

Thanks again. Is there any place where I can begin to learn how to code php? I really need to learn.

Edited by discxpress, 23 November 2009, 14:25.


#776 FWR Media

  • Community Member
  • 6,462 posts
  • Real Name:Robert Fisher
  • Gender:Male
  • Location:Stowmarket - Suffolk - UK

Posted 23 November 2009, 14:36

View Postdiscxpress, on 23 November 2009, 14:17, said:

Thanks. It works out just fine. It loads fast. With the code you suggested the page loads Current Parse Time: 0.835 s with 367 queries compared to 20.176s with 367 queries.

Thanks again. Is there any place where I can begin to learn how to code php? I really need to learn.

Oh just 1800% faster then :blink:

Glad it helped you out.
Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls

KissMT Dynamic SEO Meta & Canonical Header Tags

KissER Error Handling and Debugging

If you found my post useful please click the green + sign to the right

Please only PM me for paid work.


#777 KJ666

  • Community Member
  • 246 posts
  • Real Name:Kieron

Posted 24 November 2009, 08:50

Can anyone tell me how to get rid of these ones ?
[9] => select startdate, counter from counter
[10] => update counter set counter = '26614'
[11] => select count(*) as total from sessions where sesskey = 'gr486ea4cvuno8a9o3m9lg0gb3'

And this one:
[3] => select count(*) as count from whos_online where session_id = 'gr486ea4cvuno8a9o3m9lg0gb3'
[4] => update whos_online set customer_id = '0', full_name = 'Guest', ip_address = '**********', time_last_click = '1259052372', last_page_url = '/' where session_id = 'gr486ea4cvuno8a9o3m9lg0gb3'

#778 discxpress

  • Community Member
  • 286 posts
  • Real Name:Lecarl Butler
  • Gender:Male

Posted 25 November 2009, 08:45

View PostJan Zonjee, on 21 November 2009, 18:34, said:

Indeed, but it actually replicates the same thing that tep_get_category_tree does. Using a slightly adapted tep_get_category_tree optimization seems to give the same results but should be producing a lot less queries.

Add to includes/functions/general.php:
  function tep_get_subcategory_tree($parent_id = '0', $spacing = '', $exclude = '', $category_tree_array = '', $include_itself = false) {
    global $languages_id;

    if (!is_array($category_tree_array)) $category_tree_array = array();
    if ( (sizeof($category_tree_array) < 1) && ($exclude != '0') ) $category_tree_array[] = array('id' => '0', 'text' => TEXT_TOP);

    if ($include_itself) {
      $category_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd where cd.language_id = '" . (int)$languages_id . "' and cd.categories_id = '" . (int)$parent_id . "'");
      $category = tep_db_fetch_array($category_query);
      $category_tree_array[] = array('id' => $parent_id, 'text' => $category['categories_name']);
    }

    $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and c.parent_id = '" . (int)$parent_id . "' order by c.sort_order, cd.categories_name");
    while ($categories = tep_db_fetch_array($categories_query)) {
      if ($exclude != $categories['categories_id']) $category_tree_array[] = array('id' => $categories['categories_id'], 'text' => $spacing . $categories['categories_name']);
      $category_tree_array = tep_get_category_tree($categories['categories_id'], $spacing . '&nbsp;&nbsp;&nbsp;', $exclude, $category_tree_array);
    }

    return $category_tree_array;
  }

    function tep_get_category_tree($parent_id = '0', $spacing = '', $exclude = '', $category_tree_array = '', $include_itself = false) {
    global $languages_id;

    if (!is_array($category_tree_array)) $category_tree_array = array();
    if ( (sizeof($category_tree_array) < 1) && ($exclude != '0') ) $category_tree_array[] = array('id' => '0', 'text' => BOX_ALL_CATEGORIES);

    $category_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id, pcategories.parent_id as grand_parent_id from " . TABLE_CATEGORIES . " c  left join " . TABLE_CATEGORIES . " AS pcategories on pcategories.categories_id = c.parent_id," . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by grand_parent_id, c.parent_id, c.sort_order, cd.categories_name");

    while ($categories = tep_db_fetch_array($category_query)) {
	$_category_tree_array[] = array('grand_parent_id' => $categories['grand_parent_id'], 'parent_id' => $categories['parent_id'], 'id' => $categories['categories_id'], 'text' => ($categories['parent_id'] != '0' ? "&nbsp;&nbsp;&nbsp;".$categories['categories_name']: $categories['categories_name']));  
    } 

    if ($parent_id == '0') {
    foreach ($_category_tree_array as $index_of => $sub_array) {
	    if (!tep_not_null($sub_array['grand_parent_id'])) {
		    $parent_categories[] = array('id' => $sub_array['id'], 'text' =>  $sub_array['text']);		   
       }
    } // end foreach ($_category_tree_array as $index_of => $sub_array)
    } else { // parent_id is set, get a subset (used for deleting a category, with subcats and products)
	 foreach ($_category_tree_array as $index_of => $sub_array) {
	    if ($sub_array['id'] == $parent_id) {
		    $parent_categories[] = array('id' => $sub_array['id'], 'text' =>  $sub_array['text']);		   
       }
    } // end foreach ($_category_tree_array as $index_of => $sub_array)
    }

    for ($x = 0; $x < count($parent_categories); $x++) {
	    array_push($category_tree_array, $parent_categories[$x]);
	    foreach($_category_tree_array as $index_of_cta => $sub_array_cta) {
		    if ($sub_array_cta['parent_id'] == $parent_categories[$x]['id']) {
			    array_push($category_tree_array, array_slice($_category_tree_array[$index_of_cta], 2));
			    // BOF insert subsubcategories and everything below that
			    $categories_counter = $sub_array_cta['id'];
			    // delete the sorted category from the array, less to loop through
			    unset($_category_tree_array[$index_of_cta]);
			    $add_more_subcategories = tep_add_subcategory_to_tree($category_tree_array, $_category_tree_array, $parent_categories, $categories_counter, '2');
			    $category_tree_array = $add_more_subcategories['cat_tree'];
			    $_category_tree_array = $add_more_subcategories['_cat_tree'];
			    // EOF insert subsubcategories and everything below that
		    }
	    }
    }
    return $category_tree_array;
  } 

  function tep_add_subcategory_to_tree($category_tree_array, $_category_tree_array, $parent_categories, $categories_counter, $level) {
	  foreach($_category_tree_array as $index_of_cta => $sub_array_cta) {
		    if ($sub_array_cta['parent_id'] ==  $categories_counter && !in_array($categories_counter, $parent_categories) ) {
			    $subcategory_to_add = array_slice($_category_tree_array[$index_of_cta],2);
			    $spacing = '';
			    for ($i = 1; $i < $level ; $i++) { $spacing .= "&nbsp;&nbsp;&nbsp;"; }
			    $subcategory_to_add['text'] = $spacing.$subcategory_to_add['text'];
			    array_push($category_tree_array, $subcategory_to_add);
			    $cat_counter = $sub_array_cta['id'];
			    // delete the sorted category from the array, less to loop through
			    unset($_category_tree_array[$index_of_cta]);
			    // tep_add_subcategory_to_tree keeps calling itself to add the subcategories
			    $add_more_subcategories = tep_add_subcategory_to_tree($category_tree_array, $_category_tree_array, $parent_categories, $cat_counter, $level+1);
			    $category_tree_array = $add_more_subcategories['cat_tree'];
			    $_category_tree_array = $add_more_subcategories['_cat_tree'];
		    }
	    }
	    $resultant = array('cat_tree' => $category_tree_array, '_cat_tree' => $_category_tree_array);
	    return $resultant;
  } // end function tep_add_subcategory_to_tree

Note that the original tep_get_category_tree uses TEXT_TOP for the first entry in the dropdown menu. Changed that to BOX_ALL_CATEGORIES that you use.

Change:
<?php echo tep_draw_form('search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get') . tep_draw_hidden_field('search_in_description','1') . tep_draw_input_field('keywords', 'enter keywords', 'size="10" maxlength="30" style="width: ' . (BOX_WIDTH+150) . 'px"') . ' ' . tep_draw_pull_down_menu('categories_id', tep_get_categories(array(array('parent_id' => '', 'text' => BOX_ALL_CATEGORIES)))) . ' ' . tep_hide_session_id() . tep_image_submit('button_search.gif', IMAGE_BUTTON_SEARCH, 'align="middle"') . '</form>'; ?></td>
To:
<?php echo tep_draw_form('search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get') . tep_draw_hidden_field('search_in_description','1') . tep_draw_input_field('keywords', 'enter keywords', 'size="10" maxlength="30" style="width: ' . (BOX_WIDTH+150) . 'px"') . ' ' . tep_draw_pull_down_menu('categories_id', tep_get_category_tree(), '0') . ' ' . tep_hide_session_id() . tep_image_submit('button_search.gif', IMAGE_BUTTON_SEARCH, 'align="middle"') . '</form>'; ?></td>
Jan
The fix for the search box doesn't work properly. It doesn't return any products in the search results.

Thanks

Edited by discxpress, 25 November 2009, 08:50.


#779 Jan Zonjee

  • Team Member
  • 6,975 posts
  • Real Name:Jan Zonjee
  • Gender:Male
  • Location:the Netherlands

Posted 28 November 2009, 21:19

View Postdiscxpress, on 25 November 2009, 08:45, said:

The fix for the search box doesn't work properly. It doesn't return any products in the search results.
The only change that this code introduced was changing the first option in the dropdown friom <option value="" SELECTED>All categories</option> to <option value="0" SELECTED>All categories</option>

That change might be the reason. You can fix that by changing the function tep_get_category_tree in you catalog/include/functions/general.php

Your function has a few lines into the code:

   if ( (sizeof($category_tree_array) < 1) && ($exclude != '0') ) $category_tree_array[] = array('id' => '0', 'text' => BOX_ALL_CATEGORIES);
If you change it to:
   if ( (sizeof($category_tree_array) < 1) && ($exclude != '0') ) $category_tree_array[] = array('id' => '', 'text' => BOX_ALL_CATEGORIES);
the code it outputs is exactly the same as you had so I suppose it should work again.

#780 Stealth1

  • Community Member
  • 334 posts
  • Real Name:Chris

Posted 05 January 2010, 23:21

I am just starting to look into optimizing my store and am looking for advice on where and how to start. I did the tax class thing and it seemed to make a decent improvement but I definitely have a long way to go. I have tried reading through many pages of this thread but I am finding the advice is either above my current experience or is talked about but isn't shown how to be done.

Here is where I am at right now, when I get into the pages that display products etc I am getting over 1000 queries

Quote

Current Parse Time: 2.363 s with 1014 queries

Product Info pages I am getting the below

Quote

Current Parse Time: 1.009 s with 55 queries

Index.php

Quote

Current Parse Time: 0.105 s with 60 queries
QUERY DEBUG:

Array
(
[QUERIES] => Array
(
[0] => select tax_description from tax_rates tr left join zones_to_geo_zones za on (tr.tax_zone_id = za.geo_zone_id) left join geo_zones tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = '0') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '0') and tr.tax_class_id = '0' order by tr.tax_priority
[1] => select value from sessions where sesskey = 'a3a0d3985787720c3edf9bf93f2bd0fe' and expiry > '1262733421'
[2] => select code, title, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, value from currencies
[3] => select languages_id, name, code, image, directory from languages order by sort_order
[4] => delete from whos_online where time_last_click < '1262732521'
[5] => select count(*) as count from whos_online where session_id = 'a3a0d3985787720c3edf9bf93f2bd0fe'
[6] => insert into whos_online (customer_id, full_name, session_id, ip_address, time_entry, time_last_click, last_page_url) values ('0', 'Guest', 'a3a0d3985787720c3edf9bf93f2bd0fe', '67.71.41.199', '1262733421', '1262733421', '/store/')
[7] => select banners_id, date_scheduled from banners where date_scheduled != ''
[8] => select b.banners_id, b.expires_date, b.expires_impressions, sum(bh.banners_shown) as banners_shown from banners b, banners_history bh where b.status = '1' and b.banners_id = bh.banners_id group by b.banners_id
[9] => select specials_id from specials where status = '1' and now() >= expires_date and expires_date > 0
[10] => select products_id, products_image, products_tax_class_id, products_price from products where products_status = '1' order by products_date_added desc limit 10
[11] => select products_name from products_description where products_id = '1035' and language_id = '1'
[12] => select products_price, products_model from products where products_id = '1035'
[13] => select specials_new_products_price from specials where products_id = '1035' and status
[14] => select categories_id from products_to_categories where products_id = '1035'
[15] => select sale_specials_condition, sale_deduction_value, sale_deduction_type from salemaker_sales where sale_categories_all like '%,187,%' and sale_status = '1' and (sale_date_start <= now() or sale_date_start = '0000-00-00') and (sale_date_end >= now() or sale_date_end = '0000-00-00') and (sale_pricerange_from <= '335.0000' or sale_pricerange_from = '0') and (sale_pricerange_to >= '335.0000' or sale_pricerange_to = '0')
[16] => select sum(tax_rate) as tax_rate from tax_rates tr left join zones_to_geo_zones za on (tr.tax_zone_id = za.geo_zone_id) left join geo_zones tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = '38') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '74') and tr.tax_class_id = '5' group by tr.tax_priority
[17] => select products_id, products_image, products_tax_class_id, products_price from products where products_status = '1' order by products_date_added desc limit 6
[18] => select products_price, products_model from products where products_id = '1044'
[19] => select specials_new_products_price from specials where products_id = '1044' and status
[20] => select categories_id from products_to_categories where products_id = '1044'
[21] => select sale_specials_condition, sale_deduction_value, sale_deduction_type from salemaker_sales where sale_categories_all like '%,137,%' and sale_status = '1' and (sale_date_start <= now() or sale_date_start = '0000-00-00') and (sale_date_end >= now() or sale_date_end = '0000-00-00') and (sale_pricerange_from <= '120.0000' or sale_pricerange_from = '0') and (sale_pricerange_to >= '120.0000' or sale_pricerange_to = '0')
[22] => select products_name from products_description where products_id = '1044' and language_id = '1'
[23] => select products_price, products_model from products where products_id = '1043'
[24] => select specials_new_products_price from specials where products_id = '1043' and status
[25] => select categories_id from products_to_categories where products_id = '1043'
[26] => select sale_specials_condition, sale_deduction_value, sale_deduction_type from salemaker_sales where sale_categories_all like '%,167,%' and sale_status = '1' and (sale_date_start <= now() or sale_date_start = '0000-00-00') and (sale_date_end >= now() or sale_date_end = '0000-00-00') and (sale_pricerange_from <= '265.0000' or sale_pricerange_from = '0') and (sale_pricerange_to >= '265.0000' or sale_pricerange_to = '0')
[27] => select products_name from products_description where products_id = '1043' and language_id = '1'
[28] => select products_price, products_model from products where products_id = '1042'
[29] => select specials_new_products_price from specials where products_id = '1042' and status
[30] => select categories_id from products_to_categories where products_id = '1042'
[31] => select sale_specials_condition, sale_deduction_value, sale_deduction_type from salemaker_sales where sale_categories_all like '%,135,%' and sale_status = '1' and (sale_date_start <= now() or sale_date_start = '0000-00-00') and (sale_date_end >= now() or sale_date_end = '0000-00-00') and (sale_pricerange_from <= '265.0000' or sale_pricerange_from = '0') and (sale_pricerange_to >= '265.0000' or sale_pricerange_to = '0')
[32] => select products_name from products_description where products_id = '1042' and language_id = '1'
[33] => select products_price, products_model from products where products_id = '1041'
[34] => select specials_new_products_price from specials where products_id = '1041' and status
[35] => select categories_id from products_to_categories where products_id = '1041'
[36] => select sale_specials_condition, sale_deduction_value, sale_deduction_type from salemaker_sales where sale_categories_all like '%,62,%' and sale_status = '1' and (sale_date_start <= now() or sale_date_start = '0000-00-00') and (sale_date_end >= now() or sale_date_end = '0000-00-00') and (sale_pricerange_from <= '265.0000' or sale_pricerange_from = '0') and (sale_pricerange_to >= '265.0000' or sale_pricerange_to = '0')
[37] => select products_name from products_description where products_id = '1041' and language_id = '1'
[38] => select products_price, products_model from products where products_id = '1040'
[39] => select specials_new_products_price from specials where products_id = '1040' and status
[40] => select categories_id from products_to_categories where products_id = '1040'
[41] => select sale_specials_condition, sale_deduction_value, sale_deduction_type from salemaker_sales where sale_categories_all like '%,111,%' and sale_status = '1' and (sale_date_start <= now() or sale_date_start = '0000-00-00') and (sale_date_end >= now() or sale_date_end = '0000-00-00') and (sale_pricerange_from <= '265.0000' or sale_pricerange_from = '0') and (sale_pricerange_to >= '265.0000' or sale_pricerange_to = '0')
[42] => select products_name from products_description where products_id = '1040' and language_id = '1'
[43] => select products_price, products_model from products where products_id = '1039'
[44] => select specials_new_products_price from specials where products_id = '1039' and status
[45] => select categories_id from products_to_categories where products_id = '1039'
[46] => select sale_specials_condition, sale_deduction_value, sale_deduction_type from salemaker_sales where sale_categories_all like '%,108,%' and sale_status = '1' and (sale_date_start <= now() or sale_date_start = '0000-00-00') and (sale_date_end >= now() or sale_date_end = '0000-00-00') and (sale_pricerange_from <= '295.0000' or sale_pricerange_from = '0') and (sale_pricerange_to >= '295.0000' or sale_pricerange_to = '0')
[47] => select products_name from products_description where products_id = '1039' and language_id = '1'
[48] => select p.products_id, pd.products_name, products_date_available as date_expected from products p, products_description pd where to_days(products_date_available) >= to_days(now()) and p.products_id = pd.products_id and pd.language_id = '1' order by date_expected desc limit 10
[49] => select distinct p.products_id, pd.products_name from products p, products_description pd where p.products_status = '1' and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '1' order by p.products_ordered desc, pd.products_name limit 10
[50] => select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from products p, products_description pd, specials s where p.products_status = '1' and p.products_id = s.products_id and pd.products_id = s.products_id and pd.language_id = '1' and s.status = '1' order by s.specials_date_added desc limit 10
[51] => select r.reviews_id, r.reviews_rating, p.products_id, p.products_image, pd.products_name from reviews r, reviews_description rd, products p, products_description pd where p.products_status = '1' and p.products_id = r.products_id and r.reviews_id = rd.reviews_id and rd.languages_id = '1' and p.products_id = pd.products_id and pd.language_id = '1' order by r.reviews_id desc limit 10
[52] => select substring(reviews_text, 1, 60) as reviews_text from reviews_description where reviews_id = '3' and languages_id = '1'
[53] => select startdate, counter from counter
[54] => update counter set counter = '668047'
[55] => select banners_id, banners_title, banners_image, banners_html_text from banners where status = '1' and banners_group = '468x50'
[56] => select count(*) as count from banners_history where banners_id = '1' and date_format(banners_history_date, '%Y%m%d') = date_format(now(), '%Y%m%d')
[57] => update banners_history set banners_shown = banners_shown + 1 where banners_id = '1' and date_format(banners_history_date, '%Y%m%d') = date_format(now(), '%Y%m%d')
[58] => select count(*) as total from sessions where sesskey = 'a3a0d3985787720c3edf9bf93f2bd0fe'
[59] => update sessions set expiry = '1262734861', value = 'cart|O:12:\"shoppingCart\":5:{s:8:\"contents\";a:0:{}s:5:\"total\";i:0;s:6:\"weight\";i:0;s:12:\"content_type\";b:0;s:9:\"shiptotal\";s:0:\"\";}language|s:7:\"english\";languages_id|s:1:\"1\";currency|s:3:\"CAD\";navigation|O:17:\"navigationHistory\":2:{s:4:\"path\";a:1:{i:0;a:4:{s:4:\"page\";s:9:\"index.php\";s:4:\"mode\";s:6:\"NONSSL\";s:3:\"get\";a:0:{}s:4:\"post\";a:0:{}}}s:8:\"snapshot\";a:0:{}}' where sesskey = 'a3a0d3985787720c3edf9bf93f2bd0fe'
)

[TIME] => Array
(
[0] => 0.000778
[1] => 0.000415
[2] => 0.000266
[3] => 0.000362
[4] => 0.000819
[5] => 0.000540
[6] => 0.000150
[7] => 0.000251
[8] => 0.000556
[9] => 0.000321
[10] => 0.000595
[11] => 0.000410
[12] => 0.000144
[13] => 0.000113
[14] => 0.000294
[15] => 0.000355
[16] => 0.000430
[17] => 0.000220
[18] => 0.000127
[19] => 0.000082
[20] => 0.000117
[21] => 0.000182
[22] => 0.000115
[23] => 0.000116
[24] => 0.000159
[25] => 0.000157
[26] => 0.000162
[27] => 0.000114
[28] => 0.000117
[29] => 0.000079
[30] => 0.000115
[31] => 0.000161
[32] => 0.000108
[33] => 0.000113
[34] => 0.000078
[35] => 0.000106
[36] => 0.000265
[37] => 0.000248
[38] => 0.000154
[39] => 0.000104
[40] => 0.000142
[41] => 0.000181
[42] => 0.000122
[43] => 0.000117
[44] => 0.000083
[45] => 0.000103
[46] => 0.000164
[47] => 0.000109
[48] => 0.001698
[49] => 0.012823
[50] => 0.000296
[51] => 0.000792
[52] => 0.000140
[53] => 0.000213
[54] => 0.000114
[55] => 0.000152
[56] => 0.000723
[57] => 0.000993
[58] => 0.000109
[59] => 0.000188

If I select a category from Index.php

Quote

QUERY DEBUG:

Array
(
[QUERIES] => Array
(
[0] => select tax_description from tax_rates tr left join zones_to_geo_zones za on (tr.tax_zone_id = za.geo_zone_id) left join geo_zones tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = '0') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '0') and tr.tax_class_id = '0' order by tr.tax_priority
[1] => select value from sessions where sesskey = 'a3a0d3985787720c3edf9bf93f2bd0fe' and expiry > '1262733471'
[2] => select code, title, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, value from currencies
[3] => delete from whos_online where time_last_click < '1262732571'
[4] => select count(*) as count from whos_online where session_id = 'a3a0d3985787720c3edf9bf93f2bd0fe'
[5] => update whos_online set customer_id = '0', full_name = 'Guest', ip_address = '67.71.41.199', time_last_click = '1262733471', last_page_url = '/store/index.php/subaru-c-22' where session_id = 'a3a0d3985787720c3edf9bf93f2bd0fe'
[6] => select banners_id, date_scheduled from banners where date_scheduled != ''
[7] => select b.banners_id, b.expires_date, b.expires_impressions, sum(bh.banners_shown) as banners_shown from banners b, banners_history bh where b.status = '1' and b.banners_id = bh.banners_id group by b.banners_id
[8] => select specials_id from specials where status = '1' and now() >= expires_date and expires_date > 0
[9] => select categories_name from categories_description where categories_id = '22' and language_id = '1'
[10] => select count(*) as total from products_to_categories where categories_id = '22'
[11] => select count(*) as total from categories where parent_id = '22'
[12] => select products_id, products_image, products_tax_class_id, products_price from products where products_status = '1' order by products_date_added desc limit 10
[13] => select products_name from products_description where products_id = '1037' and language_id = '1'
[14] => select products_price, products_model from products where products_id = '1037'
[15] => select specials_new_products_price from specials where products_id = '1037' and status
[16] => select categories_id from products_to_categories where products_id = '1037'
[17] => select sale_specials_condition, sale_deduction_value, sale_deduction_type from salemaker_sales where sale_categories_all like '%,173,%' and sale_status = '1' and (sale_date_start <= now() or sale_date_start = '0000-00-00') and (sale_date_end >= now() or sale_date_end = '0000-00-00') and (sale_pricerange_from <= '264.9900' or sale_pricerange_from = '0') and (sale_pricerange_to >= '264.9900' or sale_pricerange_to = '0')
[18] => select sum(tax_rate) as tax_rate from tax_rates tr left join zones_to_geo_zones za on (tr.tax_zone_id = za.geo_zone_id) left join geo_zones tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = '38') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '74') and tr.tax_class_id = '5' group by tr.tax_priority
[19] => select cd.categories_name, c.categories_image from categories c, categories_description cd where c.categories_id = '22' and cd.categories_id = '22' and cd.language_id = '1'
[20] => select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from categories c, categories_description cd where c.parent_id = '22' and c.categories_id = cd.categories_id and cd.language_id = '1' order by sort_order, cd.categories_name
[21] => select parent_id from categories where categories_id = '22'
[22] => select parent_id from categories where categories_id = '235'
[23] => select parent_id from categories where categories_id = '22'
[24] => select parent_id from categories where categories_id = '34'
[25] => select parent_id from categories where categories_id = '22'
[26] => select parent_id from categories where categories_id = '23'
[27] => select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_price from products p, products_to_categories p2c, categories c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '22' and p.products_status = '1' order by p.products_date_added desc limit 6
[28] => select distinct p.products_id, pd.products_name from products p, products_description pd, products_to_categories p2c, categories c where p.products_status = '1' and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and '22' in (c.categories_id, c.parent_id) order by p.products_ordered desc, pd.products_name limit 10
[29] => select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from products p, products_description pd, specials s where p.products_status = '1' and p.products_id = s.products_id and pd.products_id = s.products_id and pd.language_id = '1' and s.status = '1' order by s.specials_date_added desc limit 10
[30] => select r.reviews_id, r.reviews_rating, p.products_id, p.products_image, pd.products_name from reviews r, reviews_description rd, products p, products_description pd where p.products_status = '1' and p.products_id = r.products_id and r.reviews_id = rd.reviews_id and rd.languages_id = '1' and p.products_id = pd.products_id and pd.language_id = '1' order by r.reviews_id desc limit 10
[31] => select substring(reviews_text, 1, 60) as reviews_text from reviews_description where reviews_id = '3' and languages_id = '1'
[32] => select startdate, counter from counter
[33] => update counter set counter = '668048'
[34] => select banners_id, banners_title, banners_image, banners_html_text from banners where status = '1' and banners_group = '468x50'
[35] => select count(*) as count from banners_history where banners_id = '1' and date_format(banners_history_date, '%Y%m%d') = date_format(now(), '%Y%m%d')
[36] => update banners_history set banners_shown = banners_shown + 1 where banners_id = '1' and date_format(banners_history_date, '%Y%m%d') = date_format(now(), '%Y%m%d')
[37] => select count(*) as total from sessions where sesskey = 'a3a0d3985787720c3edf9bf93f2bd0fe'
[38] => update sessions set expiry = '1262734911', value = 'cart|O:12:\"shoppingCart\":6:{s:8:\"contents\";a:0:{}s:5:\"total\";i:0;s:6:\"weight\";i:0;s:6:\"cartID\";N;s:12:\"content_type\";b:0;s:9:\"shiptotal\";s:0:\"\";}language|s:7:\"english\";languages_id|s:1:\"1\";currency|s:3:\"CAD\";navigation|O:17:\"navigationHistory\":2:{s:4:\"path\";a:1:{i:0;a:4:{s:4:\"page\";s:9:\"index.php\";s:4:\"mode\";s:6:\"NONSSL\";s:3:\"get\";a:1:{s:5:\"cPath\";s:2:\"22\";}s:4:\"post\";a:0:{}}}s:8:\"snapshot\";a:0:{}}' where sesskey = 'a3a0d3985787720c3edf9bf93f2bd0fe'
)

[TIME] => Array
(
[0] => 0.000849
[1] => 0.000444
[2] => 0.000299
[3] => 0.000831
[4] => 0.000569
[5] => 0.003495
[6] => 0.000406
[7] => 0.000642
[8] => 0.000288
[9] => 0.000304
[10] => 0.001833
[11] => 0.000323
[12] => 0.000732
[13] => 0.000261
[14] => 0.000185
[15] => 0.000103
[16] => 0.000223
[17] => 0.000318
[18] => 0.000425
[19] => 0.000250
[20] => 0.000443
[21] => 0.000143
[22] => 0.000104
[23] => 0.000274
[24] => 0.000113
[25] => 0.001911
[26] => 0.000193
[27] => 0.020255
[28] => 0.021694
[29] => 0.020626
[30] => 0.000925
[31] => 0.000169
[32] => 0.000403
[33] => 0.000159
[34] => 0.000214
[35] => 0.000805
[36] => 0.001067
[37] => 0.000165
[38] => 0.000302