-
Notifications
You must be signed in to change notification settings - Fork 219
Product Filters > Fix Performance issue and Fatal error on stores with a high volume of products #10198
Conversation
…eturned by the Store API for certain use-cases.
The release ZIP for this PR is accessible via:
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. |
Size Change: +3.05 kB (0%) Total Size: 1.36 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR 🙌
I agree it brings consistency to how the filter works as agreed in the discussion #9023 and it's great it fixes the performance problem!
I'm approving, but before merging, could you please remove references to All Products block from the PR description as I don't think it's affected by this problem at all. It's Products (Beta) and Product Collection (which is still experimental and not available to use). Unless I'm missing something?
As a next step, let's keep discussing filters along with the custom-configured Products (Beta) block (but that's the next chapter!)
Hi @nefeline 👋
I think it’s applicable for all filters instead of just the handpicked products filter. If any filter changes the number of products that will be visible on frontend then this is applicable. For example:
In short, if there is any filter that we apply in Products beta or Product collection block, which reduces the number of products to be visible on frontend then it will be applicable. I'm not entirely certain if we're on the same page regarding this, so I wanted to make sure I overcommunicate here to prevent any potential confusion 🙂 |
Thanks for the review @kmanijak and @imanish003 ! Regarding:
Yep, good call! I replaced all occurrences of All Products with Product Collection. Can any of you please re-review this PR 🙏 ? I pushed some changes on 1b4131f as I noticed the filters were not working alongside the Product Collection block, now they do. |
Yep! Handpicked products was just a use-case example.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can any of you please re-review this PR 🙏 ? I pushed some changes on 1b4131f as I noticed the filters were not working alongside the Product Collection block, now they do.
I double-checked Products and Product Collection ✅
…h a high volume of products (#10198) * Remove queries that fetch all products for manipulating the results returned by the Store API for certain use-cases. * Keep support for Product Collection block
* Empty commit for release pull request * Product Filters > Fix Performance issue and Fatal error on stores with a high volume of products (#10198) * Remove queries that fetch all products for manipulating the results returned by the Store API for certain use-cases. * Keep support for Product Collection block * Stop reading Product IDs from asset store in filter blocks (#10195) * Remove queries that fetch all products for manipulating the results returned by the Store API for certain use-cases. * Remove the code that's supposed to read product ids for filter context and logic around that in useCollectionData * Fix incorrect merge --------- Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com> * Add testing instructions for 10.6.1 * Fix margin issue with the Proceed to checkout button on the site editor (#10182) * Fix margin issue with the Proceed to checkout button on the site editor * Remove unecessary selector * Merge pull request from GHSA-gxfx-93xq-pr6p * Add cors check * refactor logic * Refactor add_cors_headers to allow null and allowed hosts * Move remove_filter inline * Revert unrelated code style changes * Add explainer to docblock * Remove access for null origin * Move CORS handling to auth class so it applies API wide * Move only Authentication to priority 11 * Handle preflight requests so cart-tokens work --------- Co-authored-by: Mike Jolley <mike.jolley@me.com> * Add changelog to readme * Bump versions, readme, changelog, and testing notes * Add testing zip * fix migration (#10205) * New testing zip * Don't send headers early in Store API (#10241) * Replace sanitization functions to enforce string values (#10242) * New testing zip * Update changelog --------- Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com> Co-authored-by: Karol Manijak <20098064+kmanijak@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com> Co-authored-by: Alex Florisca <alex.florisca@automattic.com> Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com> Co-authored-by: Mike Jolley <mike.jolley@me.com> Co-authored-by: Luigi Teschio <gigitux@gmail.com>
This PR fixes the issue initially reported on pdnLyh-3VR-p2 by removing the SQL queries used to manipulate the product counts for filters in particular cases. These queries were triggered for 100% of the stores using the Products (Beta) or the Product Collection blocks, independent of their usage of the Product Filters. Consequently, they negatively affected all stores' performance and triggered memory exhaustion errors for big e-commerces with thousands of products.
What these queries were used for?
A practical use-case example is: when adding the Products (beta) block on any post or page, it is possible to edit a setting under "Advanced Filters" that allows you to handpick specific products for display instead of showing all of them by default:
If any user decided to use the Filter by Attribute, Filter by Rating, or the Filter by Stock blocks with the filter counts enabled (they are disabled by default) alongside the Products (Beta) block that is just rendering a handful of products, these queries would manipulate the product counts to match the displayed products, and not all available products in the store right before rendering the block.
In other words, these queries were modifying the native behavior of the filter counts, and as a consequence, they were not aligned with the design decisions made a few cycles ago. With the changes introduced here, all filter counts now provide the same functionality across the board, independent of their use cases.
Discussion
There's an ongoing internal discussion, opened by @kmanijak, to gather feedback from the design team in case we wanna open an exception for this use case in particular and deviate from the design decision made previously. Depending on the outcome of that discussion, more changes will follow. (ref. per0F9-Rh-p2 )
Its also important to note that these queries are not necessary for maintaining the functionality of the filters or the filter counts; the get_attribute_counts method is.
User Facing Testing
WooCommerce Visibility
Performance Impact
This update will positively impact performance as two heavy queries were removed from the codebase. Stores with a high volume of products should be able to use the Products Collection and Products (Beta) blocks without risking having memory exhaustion errors as a consequence.
Changelog