Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19
  1. #11
    Join Date
    Aug 2005
    Location
    Vic, Oz
    Posts
    1,905
    Plugin Contributions
    5

    Default Re: script causing cpu max limit - get_audiences_list()

    Having just had this problem myself
    I have found out a couple of relavent things

    It appears that that the check for NULL on a field used in the joins is a lot faster.
    Also a few versions of mysql had problems testing for NULL on fields not used in the joins.

    So a first improvement is to replace the o.date_purchased field with o.customers_id field

    Code:
    SELECT DISTINCT c.customers_email_address as customers_email_address, c.customers_lastname as customers_lastname, c.customers_firstname as customers_firstname FROM TABLE_CUSTOMERS c LEFT JOIN  TABLE_ORDERS o ON c.customers_id=o.customers_id WHERE o.customers_id IS NULL
    An altenative that you can try that seems to produce around the same times is
    Code:
    SELECT DISTINCT c.customers_email_address as customers_email_address, c.customers_lastname as customers_lastname, c.customers_firstname as customers_firstname FROM TABLE_CUSTOMERS c 
    WHERE c.customers_id NOT IN 
    (
    SELECT o.customers_id AS customers_id
    FROM TABLE_ORDERS o
    )
    Both of these improved my selection times considerably

    Obviously backup before trying either of these to see if they work for you

  2. #12
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: script causing cpu max limit - get_audiences_list()

    Or just add a distinct index on orders.customers_id to improve performance considerably. (v1.3.9 does this during the upgrade):
    Code:
    ALTER TABLE orders ADD INDEX customers_id (customers_id);

    Also, just a comment ... using the second approach you mentioned, the sub-select, could essentially return all records twice, thus being somewhat less efficient than the join approach.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #13
    Join Date
    Aug 2005
    Location
    Vic, Oz
    Posts
    1,905
    Plugin Contributions
    5

    Default Re: script causing cpu max limit - get_audiences_list()

    Quote Originally Posted by DrByte View Post
    Or just add a distinct index on orders.customers_id to improve performance considerably. (v1.3.9 will do this during the upgrade)


    Also, just a comment ... using the second approach you mentioned, the sub-select, could essentially return all records twice, thus being somewhat less efficient than the join approach.
    Thanks Doc
    And of course the addition of the index made the selection of the original or my 2 alternatives irrelevant.
    The speed increase from the use of the index is remarkable

  4. #14
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: script causing cpu max limit - get_audiences_list()

    Thanks for confirming that. ;)
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #15
    Join Date
    Jan 2008
    Posts
    38
    Plugin Contributions
    1

    Default Re: script causing cpu max limit - get_audiences_list()

    Quote Originally Posted by DrByte View Post
    The query in question works fine on a small dataset, but in the case of large amounts of order and/or customer data the query is not adequately optimized. So, to keep it will require fine-tuning it... It's really not high on my list of priorities of things to "fix".
    I'm a little bit horrified that ZenCart is including SQL queries that are expected to fail when used under real world conditions and need to be tweaked by end-users to work correctly.

    We have a 1.38a installation with about 16K customers and 50K customers. (Not especially high numbers for an ecommerce site.) As of today, our entire site was locking up and timing out, and I spent half the day tracking it down to this SQL query. According to the logs, this query was taking of 2,000 seconds to run. That's a HALF HOUR.

    gilby's suggestion to replace the date_purchased field with customers_id field is a good one. Seems to work just as fast on orders_id, probably because both those fields are defined as non-NULL.

    DrByte's suggestion to add an index on customers_id helped even more (though not necessary if you use orders_id instead of customers_id). Using an indexed column got the query running in .02 seconds. Quite a difference from 2000 seconds.

    Hope this fix did become a priority and was implemented in 1.3.9.

  6. #16
    Join Date
    Aug 2005
    Location
    Vic, Oz
    Posts
    1,905
    Plugin Contributions
    5

    Default Re: script causing cpu max limit - get_audiences_list()

    It was :)

    And.... You also should upgrade as well

    You will find this and many other "fixes" are included as well to improve performance.

  7. #17
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,021
    Plugin Contributions
    32

    Default Re: script causing cpu max limit - get_audiences_list()

    Quote Originally Posted by capnhairdo View Post
    Hope this fix did become a priority and was implemented in 1.3.9.
    Not to speak for the good doctor, but I do believe you misunderstood what he meant when he stated "It's really not high on my list of priorities of things to "fix" "..

    It's likely he meant that it was not a priority to fix thin in v1.3.8a since v1.3.9 was the thrust of the Zen developers focus and the issue would be addressed in THAT release... DrByte can of course confirm my interpretation.. this is how I took his words..

    Given that DrBtye also stated that this was addressed in Zen Cart 1.3.9:
    Or just add a distinct index on orders.customers_id to improve performance considerably. (v1.3.9 does this during the upgrade):
    and as gilby posted it WAS addressed in v1.3.9, it seems that the thing to do to correct your situation is to upgrade your 1.3.8a shop to the latest version of Zen Cart (v1.3.9h as of this post) or apply the changes posted (as it appears you have done)
    My Site - Zen Cart & WordPress integration specialist
    I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

  8. #18
    Join Date
    Jan 2009
    Posts
    69
    Plugin Contributions
    0

    Default Re: script causing cpu max limit - get_audiences_list()

    May i know how do i UNDO this code ?


    update query_builder set query_category = '' where query_name = 'Customers who have never completed a purchase';


    I wish to restore back to what it was before i install the SQL patch above.

    Thank you!

  9. #19
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: script causing cpu max limit - get_audiences_list()

    change set query_category = '' to set query_category = 'newsletter'
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 
Page 2 of 2 FirstFirst 12

Similar Threads

  1. USPS max weight limit
    By buildingblocks in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 15 Sep 2011, 05:01 PM
  2. max qty limit message not showing
    By jezjones29 in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 17 Feb 2010, 11:03 AM
  3. Limit the max order total...?
    By LittleOleMeDesigns in forum Addon Shipping Modules
    Replies: 13
    Last Post: 13 Feb 2009, 07:45 PM

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