Hi, I identified a slow query on two sites using WPSOLR. Both sites have rather large postmeta tables that normally do not have an bad influence on the site performance. This is the query:
SELECT distinct meta_key, meta_value FROM wp_postmeta WHERE meta_key LIKE '_%' AND meta_value like 'field_%'
On site 1 this query ran 6 times per pageview (when performing a search/filtering) which took 0,5 sec each. So 3,5 sec in total! The postmeta table holds about 700k records.
On site 2 this query ran just once per pageview (when performing a search) and that took 0,1 sec which is still relatively slow. The postmeta table holds about 90k records.
I ran the query manually and on both sites and it returned empty record sets. Seems I did not need it anyway. I found that after I disabled the option “Replace custom field name by ACF custom field label on facets” the search and filter performance went from quite slow/sluggish to pretty good/very fast.
I do not really understand what the query is trying to do. Nor what the ACF extension does. I disabled it and reindexed and still my acf fields are in the index. So question 1: What is it for exactly? Repeater field names?
And question 2: Why not store the result in a transient or find a faster way to get the ACF related required data? It should improve performance immediately.
I’m not sure what you mean by ‘only in the admin’. The query I mentioned affects the search performance not only when logged in as admin or when accessing tab 2.2 but also for anonymous front end users on every search performed.