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.



Reply With Quote
