Search is slow when using WooCommerce Tab Manager

If you are using the WooCommerce Tab Manager, it includes an option to include the tab contents in your search results. Doing this means you will seriously slow down your search results when using super speedy search. Search can only be as fast as the slowest part of the search.

This KB article shows how to fix this to get your speed back, even when using the WooCommerce Tab Manager.

Performance Impact of WooCommerce Tabs on Super Speedy Search

On one of our client’s websites, free text search was taking over 5 minutes to complete. That was on a dedicated server with everything else optimised. If you’ve been following our articles, you’ll know this is because of something called ‘table scans’ that involve reading every single item in the database.

We don’t want that at all. We want to use indexes. Usable indexes (and no table scans) make databases scale to whatever size you wish with the same speed you had when your database was small.

After the fix below, their free text search completes in under 0.2 seconds.

Disable the searchable tab option

Visit the config page for WooCommerce Tabs. Quickest way to get there is to click the Configure link from the plugins list:

Click each of the tabs in your list to edit them and disable the option to include these tabs in your search results:

Disable the global Tab search option

Apart from the per-tab search option, there is also a general option as you can see in their code:

I could not find a way to change this in their config, so to alter it, visit yourdomain.com/wp-admin/options.php and then search (CTRL+F or CMD+F) for wc_tab_manager_enable_search and change the option you see to ‘no’. It *may* be the case that this option doesn’t exist for you and if so, you’ll need to create it. Here’s what I saw when searching:

So – if the option isn’t visible, it has not been created and you’ll have to manually create it. There’s no plugin I could find to help here, so you’ll need to add the following line to your functions.php file in your theme file and then refresh your page once to create the option and then delete the line again (so it doesn’t keep running this code).

add_option('wc_tab_manager_enable_search', 'no');

Add the above line to your theme functions.php file then refresh your options.php file and check that this option now exists. If so, you can now delete this line from your functions.php file. Here’s how my options.php page looks after adding the above line to the end of the theme functions.php file:

Test search and confirm it’s super speedy again

Once you have removed these tabs from the search results, your search query will no longer be modified by the WooCommerce Tabs Manager. So, test searching and confirm it is now fast. If not, there is probably some other plugin which is also altering the search query to include a table-scan query.

(optional) Re-add the tab content as searchable content through Super Speedy Search

If you really need to search the tab content, you can reintroduce the relevant keys through the Super Speedy Search admin interface.

Here is the code that identifies the meta_keys inside the WooCommerce Tab Manager:

So – the meta keys we need to search are:

  • _product_tab_content
  • _global_tab_{$tab_id}_content

If you are using global tabs, you’ll need to figure out the tab_ids for each of your global tabs.

Once you have a list of the meta_keys you need to re-enable search capability for, visit Super Speedy Search settings and add the meta_keys into the correct box, separated by commas:

Summary

If you are getting slow search results with Super Speedy Search, it’s highly likely that another plugin is altering the search query and re-introducing table scans. The above example shows how to fix the WooCommerce Tab Manager to make it fast again.

Query Monitor can help you identify which plugins are altering the search query, and unlike in the example above, plugins and themes will commonly let you disable this slow functionality.

If you are stuck, get in touch.

Did this article answer your question?

Leave a Reply

Your email address will not be published. Required fields are marked *