-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hasSales queries are taking a really long time to execute #758
Comments
Documenting this a bit more:
Results in 15 queries, 28ms
Results in 3007 DB queries, 2,021ms Using variant.salePrice gives virtually identical results. I really think this needs to be looked into. There's currently no efficient way to show a list of on sale products. This is the only area that the system is slowing down on. The rest works like a charm. |
Hi @echantigny Thanks for bringing this to our attention. We discussed it on a call as a team last night. Due to the current architecture of sales at the moment, there is not a simple way to optimize in a significant way the use of the Having said that I am wanting to get a copy of your DB for me to reproduce and take a look at the queries generated. I have already found one "low hanging fruit" code fix that should reduce your 3007 DB queries by about 500-1000 depending on the types of sales you have set up. We hope to fully address the performance of Let me know if you can send through your database? |
Using this code:
With Eric's DB (4000+ variants and a number of category based sales) Which was timing out before, is now returning in 2-3 seconds with 127 queries This is with
|
@lukeholder For some reason, it looks like it is not working for me at all, with new errors too. This is all in a new database that has all the same products (plus newer ones) and I created the Promotion (exact same as before) after I installed the dev-develop branch (107dd69). Using this gives me an Undefined index: id
|
Because this solution is doing the limit on the product query, and then looking at each to see if they are on sale or not, it is never returning the true set of onSale products. My temporary solution consists of looping through all the sales and getting the product ids associated with them. I have not looked into validating that the sales are still active yet, but this returns the correct set of products within an acceptable timeframe. This solution does not take the User Group sales into account.
|
Re-opening as the issue is not solved. It is a performance issue with a large number of variants. |
@lukeholder Please keep in mind that the solution you currently implemented in the system is wrong. Because the hasSales is applied to the products after the query limit is applied, it never returns the correct amount of products. That part should be reverted back so people don't run into that issue. |
@echantigny should already be fixed in 9311cb2 are you on the latest |
@lukeholder I'm not. I'm finalizing my site for production so I'm staying on the Released product for now. I can't really test that anyway as it crashes my site with the 5000+ products. |
Closing this, and adding a comment to the condition builder ticket. #80 |
Description
I'm trying to build a "On Sale" page and for some reason, the queries to get those products are running extremely slow, now matter how I try to run them.
It's so slow that the Debug Toolbar isn't even showing on those pages for some reason so I can't even give you proper numbers. From the google Network waterfall:
Exact same display page, just using a different query
All games (limit 24): 614ms
Has Sales (limit 24): 20s
This is all on a publicly accessible server, but I'll need to give you credentials to get in. I'll send those to you by email if you require them to replicate.
Worth noting, I have 4757 products, with 1 variant each. I'll never have more than 1 variant.
Steps to reproduce
These are the methods I'm trying to use:
craft.products.hasVariant({hasSales: true}).limit(24).all()
craft.products.hasVariant({hasSales: true}).one()
craft.variants.hasSales(true).one()
Additional info
The text was updated successfully, but these errors were encountered: