Transients Layered Nav Counts problem (WooCommerce): verschil tussen versies

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen
Regel 54: Regel 54:
 
2168227    _transient_wc_layered_nav_counts_pa_wirxx  a:16:{i:0;b:0;s:32:"a04c7  0.34M
 
2168227    _transient_wc_layered_nav_counts_pa_wirxx  a:16:{i:0;b:0;s:32:"a04c7  0.34M
 
</pre>
 
</pre>
 +
 +
== Potential solutions ==
 +
 +
[[file:20231206-1635.png|thumb|Improvement in performance by applying a patch to ''remove'' the transient]]
 +
 +
# Using memcache [https://github.com/woocommerce/woocommerce/issues/17355#issuecomment-346607533]
 +
# Flushing via cron when it gets too big [https://github.com/woocommerce/woocommerce/issues/17355#issuecomment-346607533]. By default, they hang around for about 1 day, so it size is an issue, they should probably be flushed more often, e.g., once per hour
 +
# Removing the transient - See image
  
 
== See also ==
 
== See also ==

Versie van 6 dec 2023 15:36

The problem

We have the problem described here:

  • A couple of transients with names starting with transient_wc_layered_nav_counts_pa_ that make up about 80% of the site of table wp_options
  • Storage space for table wp_options grows with about 2GB per minute, probably because of logging, as these transients are updated constantly
  • Db crashes when running out of storage space
  • Site performance degredation, even with enough storage space available
  • Every couple of days, we have to delete transients - We have been doing this for at least a year already and only now can I connect it with the other issues
  • File /var/log/php/error.log grows as well with about 2GB/minute. Unknown if this is related

Nicely illustrated by this comment:

I confirm that since WC 3.2.1, I have to purge my MariaDB
bin log files every 5 days. With the current traffic I get
on my site (which is yet little trafic), approximately every
5 days, this transient string is so huge that it generates up
to 8 gigas of log when it's saved to the table.

Layered navigation

In WooCommerce, layered navigation refers to a filtering system that helps customers refine their search results while browsing a store. It allows shoppers to narrow down product selections based on various attributes or criteria, such as price range, size, color, brand, or any custom product attributes set by the store owner.

Layered navigation typically appears as a sidebar or series of filters on category pages or search results. When customers select specific criteria or attributes, the displayed products dynamically update to show only items that match the chosen filters. This feature enhances the user experience by making it easier for customers to find the products that meet their specific preferences or requirements.

Layered navigation counts

WC Layered navigation counts refers to counting the number of items that are within a filter. Amongst other, this used for the WC Layered Nav Widget to decide whether or not to hide an item when count is 0.

Maybe this came out of this issue about how slow the query was that does this job [1]. Hence cachching[2]

Transients

Example:

option_id                    option_name                     First characters       Size
---------   -----------------------------------------   -------------------------   -----
2168239     _transient_wc_layered_nav_counts_pa_asxxx   a:16:{i:0;b:0;s:32:"c5662   0.28M
2168225     _transient_wc_layered_nav_counts_pa_auxxx   a:16:{i:0;b:0;s:32:"4c798   0.60M
2168229     _transient_wc_layered_nav_counts_pa_coxxx   a:16:{i:0;b:0;s:32:"c3e8d   0.35M
2168221     _transient_wc_layered_nav_counts_pa_depxx   a:16:{i:0;b:0;s:32:"56496   0.36M
2168213     _transient_wc_layered_nav_counts_pa_devxx   a:16:{i:0;b:0;s:32:"4c23e   0.34M
2168235     _transient_wc_layered_nav_counts_pa_dixxx   a:16:{i:0;b:0;s:32:"258a3   0.39M
2168223     _transient_wc_layered_nav_counts_pa_lexxx   a:16:{i:0;b:0;s:32:"099f4   0.37M
2168215     _transient_wc_layered_nav_counts_pa_moxxx   a:16:{i:0;b:0;s:32:"cc751   0.38M
2168233     _transient_wc_layered_nav_counts_pa_orxxx   a:18:{i:0;b:0;s:32:"65b34  10.28M
2168237     _transient_wc_layered_nav_counts_pa_prxxx   a:16:{i:0;b:0;s:32:"4ae79   1.86M
2168231     _transient_wc_layered_nav_counts_pa_sprxx   a:16:{i:0;b:0;s:32:"c5e23   0.36M
2168217     _transient_wc_layered_nav_counts_pa_subxx   a:16:{i:0;b:0;s:32:"52a9d   0.34M
2168219     _transient_wc_layered_nav_counts_pa_widxx   a:16:{i:0;b:0;s:32:"7735d  14.90M
2168227     _transient_wc_layered_nav_counts_pa_wirxx   a:16:{i:0;b:0;s:32:"a04c7   0.34M

Potential solutions

Improvement in performance by applying a patch to remove the transient
  1. Using memcache [3]
  2. Flushing via cron when it gets too big [4]. By default, they hang around for about 1 day, so it size is an issue, they should probably be flushed more often, e.g., once per hour
  3. Removing the transient - See image

See also

Sources