Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client was experiencing a performance issue with a slow WPML query on their WooCommerce site, which took 3.5 seconds to complete. The query involved a

SELECT COUNT(...)

check that was identified as problematic.

Solution:
We recommended the client to update all outdated WPML plugins and to revert the site to a minimal setup to ensure there were no performance issues. We then advised the client to activate only the plugin responsible for creating the Cars and Models to determine if the performance problem would reoccur.

If you're experiencing similar issues, we recommend you try the following steps:
1. Update all outdated WPML plugins.
2. Revert your site to a minimal setup and check for performance improvements.
3. Activate plugins one by one to identify the source of the problem.

Please note that the solution provided might be irrelevant due to being outdated or not applicable to your case. If the issue persists, we highly recommend checking related 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 in the 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.

No supporters are available to work today on this forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Tagged: 

This topic contains 10 replies, has 2 voices.

Last updated by Carlos Rojas 7 months ago.

Assisted by: Carlos Rojas.

Author Posts
April 13, 2024 at 8:20 am #15514542

vadimP

This ticket is related to a chat I had a few days ago with one of your colleagues.

We have woocommerce pages on the site, for example like this one - hidden link

And my looking at Query Monitor there are WPML query which takes 3.5sec to complete. Is there a way to solve this?

We are already using IndexMySQL plugin to add indexes and server is quite powerful

It seems that these WPML queries with the SELECT COUNT(...) = 0 check are the worst.

Here is the query:

SELECT cwdposts.ID
FROM cwdposts
INNER JOIN cwdpostmeta
ON ( cwdposts.ID = cwdpostmeta.post_id ) JOIN cwdicl_translations wpml_translations
ON cwdposts.ID = wpml_translations.element_id
AND wpml_translations.element_type = CONCAT('post_', cwdposts.post_type)
WHERE 1=1
AND ( cwdposts.ID NOT IN (
SELECT object_id
FROM cwdterm_relationships
WHERE term_taxonomy_id IN (7,9) ) )
AND ( ( cwdpostmeta.meta_key = '_price'
AND cwdpostmeta.meta_value != '' ) )
AND ((cwdposts.post_type = 'product'
AND (cwdposts.post_status = 'publish'
OR cwdposts.post_status = 'acf-disabled'
OR cwdposts.post_status = 'private')))
AND ( ( ( wpml_translations.language_code = 'lv'
OR ( wpml_translations.language_code = 'lv'
AND cwdposts.post_type IN ( 'product','portfolio' )
AND ( ( (
SELECT COUNT(element_id)
FROM cwdicl_translations
WHERE trid = wpml_translations.trid
AND language_code = 'lv' ) = 0 )
OR ( (
SELECT COUNT(element_id)
FROM cwdicl_translations t2 JOIN cwdposts p
ON p.id = t2.element_id
WHERE t2.trid = wpml_translations.trid
AND t2.language_code = 'lv'
AND ( p.post_status = 'publish'
OR p.post_status = 'private'
OR ( p.post_type='attachment'
AND p.post_status = 'inherit' ) ) ) = 0 ) ) ) )
AND cwdposts.post_type IN ('post','page','attachment','wp_block','wp_template','wp_template_part','wp_navigation','product','product_variation','wpcf7_contact_form','portfolio' ) )
OR cwdposts.post_type NOT IN ('post','page','attachment','wp_block','wp_template','wp_template_part','wp_navigation','product','product_variation','wpcf7_contact_form','portfolio' ) )
GROUP BY cwdposts.ID
ORDER BY cwdposts.menu_order ASC, cwdposts.post_title ASC

query.png
April 15, 2024 at 9:40 am #15518692

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

Hello,
Thank you for contacting us

Could you describe step-by-step how to reproduce the issue on the site?

Regards,
Carlos

April 15, 2024 at 11:12 am #15519515

vadimP

Hey Carlos, you can check any category page from this list - hidden link

For example - hidden link

TTFB is 4sec+ from which 3.5sec goes to WPML query.

April 15, 2024 at 12:16 pm #15519903

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

Thank you for your feedback.

I would like to request temporary access (wp-admin and FTP) to your site to take a better look at the issue. You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

Our Debugging Procedures

I will be checking various settings in the backend to see if the issue can be resolved. Although I won't be making changes that affect the live site, it is still good practice to back up the site before providing us access. If we do need to debug the site further, I will duplicate the site and work in a separate, local development environment to avoid affecting the live site.

April 15, 2024 at 1:21 pm #15520311

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

Thank you for sharing the credentials requested.

There are a few cache plugins installed which is not recommended because it might cause performance issues on the site. Also, in the screenshot you shared, the 'caller' column points to the plugin W3 Total Cache which is not installed on the site and its Disk cache configuration has caused performance issues in the past.

Could you take a look at the configuration and make sure only one cache plugin is being used and active?

April 15, 2024 at 1:27 pm #15520360

vadimP

We have WP Rocket and Redis installed which both considered to be very popular and well-made solutions.

Screenshot was taken few days ago when we had W3 total cache installed, as we were testing different caching plugins hoping it will make any changes, however it wont

WP Rocket is a frontend cache and Redis is object/database cache, so they totally can be used together

April 15, 2024 at 1:28 pm #15520392

vadimP

If you want, we can disable both caches, however it will not solve that query. We've tried it. The problem with the query is not caching plugins but rather WPML queries with the SELECT COUNT(...) = 0 check

April 16, 2024 at 9:02 am #15523643

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

Thank you very much for your messages.

Could you create a staging site with a copy of the live site where we can run further tests without affecting the production site?

I have set your next message private so you can securely share the access credentials to the staging site in case you created it.

April 16, 2024 at 2:13 pm #15526170

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

Thank you very much for creating the staging site.

I updated all outdated plugins from WPML. Then left the site in a minimal setup and everything is working as expected, with no performance issues. I kindly ask you to activate just the plugin that creates the Cars and Models and then check if the performance problem appeared again.

Looking forward to your message.

April 18, 2024 at 9:50 am #15536921

vadimP

Thank you, I found few obsolete plugins, one of them being CF7 and page generation time increased by 1-1.5sec.

I will keep checking, but at the moment it looks good. Thank you!

April 18, 2024 at 10:08 am #15537204

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

Please don't hesitate to contact us if you need our help in the future with WPML. We will be more than happy to help.

Have an excellent day!