Home›Support›English Support›[Resolved] High number of duplicate queries from WPML_Element_Translation->maybe_populate_cache() on inventory ...
[Resolved] High number of duplicate queries from WPML_Element_Translation->maybe_populate_cache() on inventory ...
This thread is resolved. Here is a description of the problem and solution.
Problem: The client was experiencing performance issues on their site's archive pages, particularly with high load times and frequent errors. The WPML_Element_Translation->maybe_populate_cache() function was being called excessively, resulting in around 1,800 SELECT queries per request, significantly affecting site performance. Solution: We identified that the issue was related to the Adjust ID setting in WPML, which was trying to fetch translated IDs for menu items not set in other languages. To resolve this, we recommended the following steps: 1. Disable the Adjust ID option. 2. Navigate to WPML > String translation > Admin Texts Translation. 3. Locate the default language theme option for the main menu at [theme_mods_motors][nav_menu_locations]primary with ID 207. 4. Add this option for translation and assign the translated menu ID for other languages, such as French ID 253. After applying these changes, the site's load time improved significantly, with pages loading in about 2.5 seconds even with cache disabled. For further details on optimizing SQL queries, you can visit https://wpml.org/faq/how-to-optimize-mysql-queries/.
If this solution does not apply to your case, or if it seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. Should you need further assistance, please do not hesitate to open a new support ticket at WPML support forum.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
Background of the issue:
I am trying to improve the performance of my site, hidden link, particularly on archive pages like /inventory/. I have deactivated unnecessary translations, deleted unneeded strings from the database, and activated persistent object caching (memcached).
Symptoms:
I am experiencing performance issues on archive pages, with the site becoming almost unusable and frequently throwing 300 timeouts or 500 errors. Using Query Monitor, I see approximately 1,800 SELECT queries triggered by WPML_Element_Translation->maybe_populate_cache(), with many duplicates, especially on the /inventory/ page.
Questions:
Why is maybe_populate_cache() being called so many times in a single request?
Is there a way to batch or cache these lookups instead of repeating the same query multiple times per request?
Can you suggest WPML settings or hooks that would reduce these queries, such as disabling unnecessary translations for some post types/taxonomies or optimizing cache use?
Would WPML query caching, changing the translation mode, or disabling unused WPML features help in my case?
FYI I've already done the following things to improve speed:
- In WPML > Settings", don't use "Translatable - use translation if available or fallback to default language" for Post types and taxonomies
- Delete untranslated strings to reduce the number of strings: https://wpml.org/documentation/getting-started-guide/string-translation/#how-to-delete-a-string
- Updated the PHP version to 8.1 (what is the recommended one to use?)
- In "WPML > Support > Troubleshooting(link)", I run "Remove ghost entries from the translation tables" and "Cleanup and optimize string tables"
Welcome to the WPML support forum. Before passing this thread to my colleague, I would like to share some suggestions and possible solutions for the issues you mentioned. Sorry for the late response becuase of the holidays.
This may be a compatibility issue. We have seen a similar report in the past. But it was caused by a conflict with a WooCommerce extension. For details, please visit this ticket: https://wpml.org/forums/topic/performance-issues/
Therefore, we have a request. To track this, please follow the steps below. It will also help us to troubleshoot the issue without affecting your live site.
- Create a staging/development site (a complete clone copy of the live site).
- Temporarily switch to a default WordPress theme (e.g., Twenty Twenty-Five).
- Deactivate all plugins that are not related to WPML.
- Check whether the issue still occurs.
- If the issue is gone, reactivate plugins in small batches (3–4 at a time) and test after each batch to find the conflicting extension.
- Switch back to your original theme.
This is part of debugging procedure to try and determine from where the issue is coming and what is causing the issue. The when we have move information we can advise further or suggest officially compatible plugin alternative you can use.
If issue still happens with only WPML plugins and WP default theme, that means issue is coming somewhere from WPML plugin and we can quickly further check and escalate.
ok, I try to do what you said and come back to you as soon as possible. Actually the only ones I can deactivate are these as all the rest is mandatory for the theme and for WMPL
I deactivated the following plugins and I see zero improvements:
- Content Control
- Disable Gutenberg
- Index WP MySQL For Speed
- MU: Control External Scripts (Maps & reCAPTCHA) — Hardened
- Pressidium Cookie Consent
- User Registration & Membership
I do not have access, please share admin and FTP access, as I will need to disable all plugins and theme to check what is causing it and from where does the issue comes.
I forgot to say: in the past I did tests and I noticed that when this flag is removed the site performance shows huge improvement. The point is that if I unflag it the menu does not translate at all and keep staying in English for all editions.
thanks for getting back and providig more information.
I have updated themes, plugins including WPML to latest versions.
Issue seems to be caused by Adjust ID, because seems you are setting main menu for default language from theme options, but it is not set for other language, so WPML via Adjust ID is trying to fetch all other translated IDs and causing performance issue which is kind of expected due to SQL queries:
You can disable this option, then from WPML > String translation > Not seeing strings that you are looking for? > Admin Texts Translation > find you default language theme option that chooses menu > [theme_mods_motors][nav_menu_locations]primary and has ID of main menu 207 > Add it for translation and add for other language translated menu ID, for example french 253.
- hidden link
- hidden link
If you check now the website loads fine in 2.5s with cache disabled, so looks good.
Hi, I managed to add the ID and solve the issue with the main menu, but I see now many other problems.
- all contact form 7 forms are broken
- How do I translate the top bar menu (Help About Us Contact Us)? how do I find the string and add the IDs?
- in the listings there are english words in all other languages (f.i conditions, vehicles available etc.).
- the search on the home shows the same translation for all fields
This string [mvl_search_results_settings]listing_directory_title_default despite it is translated it does not show the translation on the front-end correctly.
I am wondering why
New threads created by Dražen and linked to this one are listed below: