You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Super Speedy Filters should use my object_ancestors table even if we're not checking for stock #60
This needs to be on a large store to reproduce the issue, e.g. I have 1 million products locally
Enable stock check from Settings > SSF
Load /shop/ - see that the main query is quite fast, e.g. 0.1s
Change the stock check from Settings > SSF to NOT check in stock by default
Reload /shop/ - on my local this now takes 7+ seconds because they have the code added to check that the products are not 'hidden from catalog'
To fix:
Add visible_in_catalog column to object_ancestors - code needs to go in table rebuild and in table maintenance functions - double check it gets updated and maintained correctly by changing a products catalog visibility
Adjust the pre_get_posts function to use my object_ancestors table, even on /shop/ when no stock check is running - i.e. it should join to object_ancestors on visible_in_catalog=1 and it should remove the NOT IN for term_relationships - code already exists to do this term_relationships removal and swap that slow code with my object_ancestors joins
Double check if the instock flag on object_ancestors also reflects 'visible in catalog' - I think i might have overloaded the purpose of this field to contain 'instock' and 'visible in catalog'.
Note re: 3 above, please investigate this first in the code and find out if the visible in catalog is included in the instock setting, I think it is.
visible in catalog is checked in a really slow way by woocommerce by creating a taxonomy for catalog_visibility with terms like 'hidden from search' and 'hidden from catalog' etc and then in the main query they check that products are NOT in that taxonomy. NOT IN is a slow SQL query pretty much always, depending on the rest of the query, but anyway - check if this is used in the current table maintenance code when setting the instock bit value and if you have any confusion contact me on discord.
SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts LEFT JOIN wp_wc_product_meta_lookup wc_product_meta_lookup ON wp_posts.ID = wc_product_meta_lookup.product_id WHERE 1=1 AND ( wp_posts.ID NOT IN ( SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id IN (7,9) ) ) AND wp_posts.post_type = 'product' AND ((wp_posts.post_status = 'publish')) GROUP BY wp_posts.ID ORDER BY wc_product_meta_lookup.min_price ASC, wc_product_meta_lookup.product_id ASC LIMIT 0, 12
Whereas when joined to object_ancestors to limit the stock, it takes 0.05 seconds.
SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts LEFT JOIN wp_wc_product_meta_lookup wc_product_meta_lookup ON wp_posts.ID = wc_product_meta_lookup.product_id JOIN wp_fww_object_ancestorsas oa1 ONwp_posts.id = oa1.ID and oa1.instock = 1 and oa1.taxonomy = 'product_cat' WHERE 1=1 AND wp_posts.post_type = 'product' AND ((wp_posts.post_status = 'publish')) GROUP BY wp_posts.ID ORDER BY wc_product_meta_lookup.min_price ASC, wc_product_meta_lookup.product_id ASC LIMIT 0, 12
Checked against SSF 6.40.4. The shared object_ancestors table is now detected, but the fast path is still entered through the stock-check branch and the table has no separate visible_in_catalog value. Suggested fix: store catalogue visibility independently and use the ancestor table whenever it is ready, regardless of the stock-check setting.
Retested on SSF 6.54.1 (beca1c0), WooCommerce 10.5.3, HPOS enabled and Storefront, with a dedicated synthetic catalogue of 1,000,000 published products. The current-core index rebuild completed before testing.
Keeping this open. The unfiltered shop still bypasses object_ancestors and retains the visibility NOT IN query. The original 0.1s versus 7s timing gap did not reproduce, but the stock-enabled baseline is also incorrect:
Request
Main query time
Products found
SSF query active
/shop/, Check Stock = Yes
0.527–0.610s, three requests
1,000,000
No
/shop/, Check Stock = No
0.563–0.605s, three requests
1,000,000
No
/shop/?stock-status=instock, default No
58.544s, one request
995,037
Yes
The catalogue contains 995,037 in-stock and 4,963 out-of-stock products. The explicit stock request uses the OA join and returns the correct count; the default stock setting on the unfiltered shop does not. The stock-enabled correctness assertion fails on all three requests. No database errors were reported. Scheduled background jobs were disabled during measurement; these are local reproduction timings, not a controlled hardware benchmark.
Fixed in 6.55.1, committed and pushed to core master (8623ab8).
The unfiltered Shop now honours the default Check Stock setting. On the retained million-product fixture, off returns 1,000,000 products and on returns the independently verified 995,037 in-stock products. The HTTP regression failed before the fix and passes afterwards; the existing category archive regression also passes.
Correction: reopening this report. Version 6.55.1 fixes the default-stock bypass discovered during reproduction, but does not implement this report's requested catalogue-visibility optimisation through object_ancestors. The original performance target and visibility maintenance still need work. The earlier closure was premature.
Activity
dhilditch commentedon Jan 26, 2024
Note re: 3 above, please investigate this first in the code and find out if the visible in catalog is included in the instock setting, I think it is.
visible in catalog is checked in a really slow way by woocommerce by creating a taxonomy for catalog_visibility with terms like 'hidden from search' and 'hidden from catalog' etc and then in the main query they check that products are NOT in that taxonomy. NOT IN is a slow SQL query pretty much always, depending on the rest of the query, but anyway - check if this is used in the current table maintenance code when setting the instock bit value and if you have any confusion contact me on discord.
voodoo911 commentedon Feb 19, 2024
@dhilditch said he will solve that issue
dhilditch commentedon Feb 23, 2024
SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts LEFT JOIN wp_wc_product_meta_lookup wc_product_meta_lookup ON wp_posts.ID = wc_product_meta_lookup.product_id WHERE 1=1 AND ( wp_posts.ID NOT IN ( SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id IN (7,9) ) ) AND wp_posts.post_type = 'product' AND ((wp_posts.post_status = 'publish')) GROUP BY wp_posts.ID ORDER BY wc_product_meta_lookup.min_price ASC, wc_product_meta_lookup.product_id ASC LIMIT 0, 12Above takes 6.8s on my local
dhilditch commentedon Feb 23, 2024
Whereas when joined to object_ancestors to limit the stock, it takes 0.05 seconds.
SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts LEFT JOIN wp_wc_product_meta_lookup wc_product_meta_lookup ON wp_posts.ID = wc_product_meta_lookup.product_id JOINwp_fww_object_ancestorsas oa1 ONwp_posts.id = oa1.ID and oa1.instock = 1 and oa1.taxonomy = 'product_cat' WHERE 1=1 AND wp_posts.post_type = 'product' AND ((wp_posts.post_status = 'publish')) GROUP BY wp_posts.ID ORDER BY wc_product_meta_lookup.min_price ASC, wc_product_meta_lookup.product_id ASC LIMIT 0, 12voodoo911 commentedon Feb 23, 2024
@dhilditch Should I implement that code to plugin ?
dhilditch commentedon Feb 23, 2024
This one I'd like to look at a bit more @voodoo911 we need to be careful with this.
dhilditch commentedon Feb 23, 2024
slow main query for large datasets.txt
dhilditch commentedon Jul 28, 2026
Checked against SSF 6.40.4. The shared object_ancestors table is now detected, but the fast path is still entered through the stock-check branch and the table has no separate visible_in_catalog value. Suggested fix: store catalogue visibility independently and use the ancestor table whenever it is ready, regardless of the stock-check setting.
dhilditch commentedon Sep 16, 2026
Retested on SSF 6.54.1 (
beca1c0), WooCommerce 10.5.3, HPOS enabled and Storefront, with a dedicated synthetic catalogue of 1,000,000 published products. The current-core index rebuild completed before testing.Keeping this open. The unfiltered shop still bypasses
object_ancestorsand retains the visibilityNOT INquery. The original 0.1s versus 7s timing gap did not reproduce, but the stock-enabled baseline is also incorrect:/shop/, Check Stock = Yes/shop/, Check Stock = No/shop/?stock-status=instock, default NoThe catalogue contains 995,037 in-stock and 4,963 out-of-stock products. The explicit stock request uses the OA join and returns the correct count; the default stock setting on the unfiltered shop does not. The stock-enabled correctness assertion fails on all three requests. No database errors were reported. Scheduled background jobs were disabled during measurement; these are local reproduction timings, not a controlled hardware benchmark.
Retained environment: http://tests-issue-60.super-speedy-filters.localhost:8081/shop/ (local to my development machine). The query traces, failing check and screenshots are retained with this environment's reproduction evidence. No fix applied.
dhilditch commentedon Sep 16, 2026
Fixed in 6.55.1, committed and pushed to core master (
8623ab8).The unfiltered Shop now honours the default Check Stock setting. On the retained million-product fixture, off returns 1,000,000 products and on returns the independently verified 995,037 in-stock products. The HTTP regression failed before the fix and passes afterwards; the existing category archive regression also passes.
This fixes the stock-setting bypass. The existing stock query took 22.21 seconds in this run; no query-speed improvement is claimed. Test environment: http://tests-issue-60.super-speedy-filters.localhost:8081/ . This is pushed source, not a deployed customer release.
dhilditch commentedon Sep 16, 2026
Correction: reopening this report. Version 6.55.1 fixes the default-stock bypass discovered during reproduction, but does not implement this report's requested catalogue-visibility optimisation through object_ancestors. The original performance target and visibility maintenance still need work. The earlier closure was premature.