Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2023
    Location
    china
    Posts
    4
    Plugin Contributions
    0

    Idea or Suggestion How to make the operation of price update faster?

    ZC version:1.5.7
    PHP version:7.4

    When I manage the price of the product and click the update button, it takes more than 10 seconds to complete. I checked the file products_price_manager.php, and after updating the price, there will be the following SQL statement:

    The result sets of these SQL are very large. Is this the cause of the problem?

    $productsFeatured = $db->Execute("SELECT p.products_id,
    f.featured_id, f.expires_date, f.featured_date_available, f.status
    FROM " . TABLE_PRODUCTS . " p,
    " . TABLE_FEATURED . " f
    WHERE p.products_id = f.products_id
    AND f.products_id = " . (int)$_GET['products_filter']);

    $productsSpecial = $db->Execute("SELECT p.products_id,
    s.specials_id, s.specials_new_products_price, s.expires_date, s.specials_date_available, s.status
    FROM " . TABLE_PRODUCTS . " p,
    " . TABLE_SPECIALS . " s
    WHERE p.products_id = s.products_id
    AND s.products_id = " . (int)$_GET['products_filter']);

    $products = $db->Execute("SELECT p.products_id, p.products_model,
    p.products_price, p.products_date_available,
    p.products_tax_class_id,
    p.products_quantity_order_min, products_quantity_order_units, p.products_quantity_order_max,
    p.product_is_free, p.product_is_call, p.products_quantity_mixed, p.products_priced_by_attribute, p.products_status,
    p.products_discount_type, p.products_discount_type_from, p.products_price_sorter,
    pd.products_name,
    p.master_categories_id, p.products_mixed_discount_quantity
    FROM " . TABLE_PRODUCTS . " p,
    " . TABLE_PRODUCTS_DESCRIPTION . " pd
    WHERE p.products_id = " . (int)$_GET['products_filter'] . "
    AND p.products_id = pd.products_id
    AND pd.language_id = " . (int)$_SESSION['languages_id']);

  2. #2
    Join Date
    Jul 2012
    Posts
    16,735
    Plugin Contributions
    17

    Default Re: How to make the operation of price update faster?

    Each of those queries appear to be seeking a single product, yet do not have a limit of 1 either in the query itself or in the call to execute.

    As a result, all product are searched for each query instead of stopping when the one match is found.

    How many product are in the database?
    Also how many featured items are there?
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Apr 2023
    Location
    china
    Posts
    4
    Plugin Contributions
    0

    Default Re: How to make the operation of price update faster?

    Quote Originally Posted by mc12345678 View Post
    Each of those queries appear to be seeking a single product, yet do not have a limit of 1 either in the query itself or in the call to execute.

    As a result, all product are searched for each query instead of stopping when the one match is found.

    How many product are in the database?
    Also how many featured items are there?
    Table of products: 480,000 lines
    featured:80,000

  4. #4
    Join Date
    Jun 2008
    Location
    Japan
    Posts
    123
    Plugin Contributions
    5

    Default Re: How to make the operation of price update faster?

    If you look at zc v1.5.8 (same file) these queries all use inner join or left join which is are more efficient. Queries from 1.5.7 you posted here are going through all database before applying Where clause.
    It looks to me that new queries from v1.5.8 could be easily uses in v1.5.7 too.
    You could although use STRAIGHT_JOIN and place smaller table first and most restrict condition first. With STRAIGHT_JOIN order is important.
    For example:
    PHP Code:
    $productsFeatured $db->Execute("SELECT p.products_id,
    f.featured_id, f.expires_date, f.featured_date_available, f.status
    FROM " 
    TABLE_FEATURED " f STRAIGHT_JOIN " TABLE_PRODUCTS " p 
    ON p.products_id = f.products_id
    WHERE f.products_id = " 
    . (int)$_GET['products_filter']); 
    This query will go through left table first, feature table which is far smaller than you product table. This is done like this for 'big data' as I know but with your table size standard INNER JOIN like used in zc v1.5.8 should be good too.
    Last edited by pilou2; 26 Apr 2023 at 11:32 AM.

  5. #5
    Join Date
    Apr 2023
    Location
    china
    Posts
    4
    Plugin Contributions
    0

    Default Re: How to make the operation of price update faster?

    Quote Originally Posted by pilou2 View Post
    If you look at zc v1.5.8 (same file) these queries all use inner join or left join which is are more efficient. Queries from 1.5.7 you posted here are going through all database before applying Where clause.
    It looks to me that new queries from v1.5.8 could be easily uses in v1.5.7 too.
    You could although use STRAIGHT_JOIN and place smaller table first and most restrict condition first. With STRAIGHT_JOIN order is important.
    For example:
    PHP Code:
    $productsFeatured $db->Execute("SELECT p.products_id,
    f.featured_id, f.expires_date, f.featured_date_available, f.status
    FROM " 
    TABLE_FEATURED " f STRAIGHT_JOIN " TABLE_PRODUCTS " p 
    ON p.products_id = f.products_id
    WHERE f.products_id = " 
    . (int)$_GET['products_filter']); 
    This query will go through left table first, feature table which is far smaller than you product table. This is done like this for 'big data' as I know but with your table size standard INNER JOIN like used in zc v1.5.8 should be good too.
    Thank you for your opinion. The query of zc1.5.7 is also very fast, but the front end is very slow.

  6. #6
    Join Date
    Aug 2009
    Location
    North Idaho, USA
    Posts
    2,008
    Plugin Contributions
    1

    Default Re: How to make the operation of price update faster?

    DBIO is a great plugin that will speed things up once you get things setup for you particular needs. Do everything in a properly formatted spreadsheet & upload.

    https://www.zen-cart.com/downloads.php?do=file&id=2091
    Rick
    RixStix (dot) com
    aka: ChainWeavers (dot) com

  7. #7
    Join Date
    Apr 2023
    Location
    china
    Posts
    4
    Plugin Contributions
    0

    Default Re: How to make the operation of price update faster?

    Quote Originally Posted by RixStix View Post
    DBIO is a great plugin that will speed things up once you get things setup for you particular needs. Do everything in a properly formatted spreadsheet & upload.

    https://www.zen-cart.com/downloads.php?do=file&id=2091
    Thank you for your help. I will try, but this is not my first choice.

 

 

Similar Threads

  1. How do I make the price to update?
    By nycxkkoma in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 7 Oct 2010, 07:30 PM
  2. How to make my site faster?
    By diane22 in forum General Questions
    Replies: 1
    Last Post: 19 Dec 2008, 03:07 AM
  3. How to make our zencart run faster ?
    By anewstone in forum General Questions
    Replies: 12
    Last Post: 19 Jun 2008, 08:20 AM
  4. how can i make my site faster
    By lucianman in forum General Questions
    Replies: 4
    Last Post: 5 Jul 2006, 11:54 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR