Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
- - 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00
- - - - - - -

Supporter timezone: America/Lima (GMT-05:00)

Tagged: 

This topic contains 57 replies, has 3 voices.

Last updated by Andreas W. 2 weeks, 5 days ago.

Assisted by: Andreas W..

Author Posts
August 15, 2024 at 4:32 am

coinQ

Background of the issue:
We have an issue with our website performance. When we checked all the c of the CPU, and load spikes are mainly due to some queries, and mostly the queries are from WPML. We have identified several queries that are taking a significant amount of time to execute, which may affect our site's performance. The queries related to fetching posts and their translations that are running slowly are: SELECT wp_posts.ID FROM wp_posts JOIN wp_icl_translations wpml_translations ON wp_posts.ID = wpml_translations.element_id AND wpml_translations.element_type = CONCAT('post_', wp_posts.post_type) WHERE 1=1 AND ( wp_posts.ID NOT IN ( SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id IN (1274,1289,4975) ) ) AND wp_posts.post_type = 'post' AND ((wp_posts.post_status = 'publish')) AND ( ( ( wpml_translations.language_code = 'en' OR ( wpml_translations.language_code = 'en' AND wp_posts.post_type IN ( 'page' ) AND ( ( ( SELECT COUNT(element_id) FROM wp_icl_translations WHERE trid = wpml_translations.trid AND language_code = 'en' ) = 0 ) OR ( ( SELECT COUNT(element_id) FROM wp_icl_translations t2 JOIN wp_posts p ON p.id = t2.element_id WHERE t2.trid = wpml_translations.trid AND t2.language_code = 'en' AND ( p.post_status = 'publish' OR p.post_status = 'private' OR ( p.post_type='attachment' AND p.post_status = 'inherit' ) ) ) = 0 ) ) ) ) AND wp_posts.post_type IN ('post','page','attachment','wp_block','wp_template','wp_template_part','wp_navigation','cookielawinfo' ) ) OR wp_posts.post_type NOT IN ('post','page','attachment','wp_block','wp_template','wp_template_part','wp_navigation','cookielawinfo' ) ) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC. Link to a page where the issue can be seen: hidden link

Symptoms:
Very slow queries and low performance.

Questions:
How can we optimize the queries related to fetching posts and their translations?
What steps can we take to improve the performance of our website when using WPML?

August 15, 2024 at 5:41 am
August 16, 2024 at 3:54 am #16076640

coinQ

Is there any update on this?

August 16, 2024 at 10:08 am #16077899

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

The issue is escalated to our 2nd tiers and it's on their queue currently, I will update you as soon as I will have any feedbacks available.

Thanks

August 19, 2024 at 8:44 am #16082453

coinQ

Hello Team,

It has been nearly five days since we raised the issue. We would appreciate it if you could provide an update on the progress.

Thank you.

August 19, 2024 at 1:26 pm #16083863

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Our 2nd tier checked the issue and suggested that there are few categories that is missing translations like "Sponsored", as well as category base slugs and labels are missing, they suggested to complete it.

Once it's completed, go to WPML > Support > Troubleshooting and run the taxonomy sync option for posts.

Let us know if this helps.

Thanks

August 19, 2024 at 6:41 pm #16084981

coinQ

Hello Team,

I didn't quite understand your explanation regarding the categories. Could you please provide more details? I've attached screenshots of the category list under the "Taxonomy Translation" page for your reference.

Additionally, could you and your technical team recommend any other changes to help resolve this issue?

Thank you for your assistance.

Best regards,

Taxonomy-translation-‹-Coin-Edition-—-WordPress.png
Taxonomy-translation-‹-Coin-Edition-—-WordPress (1).png
August 21, 2024 at 7:52 am #16088928

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

We want you translate all the remaining categories and see if the problem exists?

Also, I haven't received any further suggestions from the team.

Look forward to your reply.

Thanks

August 21, 2024 at 8:33 am #16089166

coinQ

Hello,

Why do we need to translate all categories?

We intentionally kept those categories untranslated for our English version only, as we don’t need them in other languages. Are you suggesting that this could be contributing to the slowness? If so, this seems like it might be a bug in the plugin. In scenarios like ours, we may choose not to translate all categories into different languages, but are untranslated taxonomies causing issues?

Please let me know your thoughts.

Thank you

August 21, 2024 at 9:53 am #16089560

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello 🙂

The query from your server appears to be searching for translations of the categories, which is why we recommended trying a translation it might help. However, this is not a definitive solution. To provide a more concrete answer, we would need to replicate the issue, but currently, we are unable to do so on the staging site.

Given this, I suggest you give the translation a try and see if it makes a difference. This could assist us in further debugging the issue.

Additionally, it would be helpful if you could attempt to replicate the issue on the staging server. Without a clear reproduction step, it’s challenging for us to offer a concrete solution.

Looking forward to your response.

Thanks!

August 24, 2024 at 12:05 pm #16100221

coinQ

We are still on the mentioned tasks and will update you once it complete

August 26, 2024 at 3:28 am #16102256

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Sure, also, our 2nd tier suggested the following:

This query is triggered inside the functions.php file of the client's theme: so go to /wp-content/themes/coinedition/functions.php:362

public function fetch_posts()
	{
		$args = array(
			'post_type' => 'post', //"post" post type
			'post_status' => 'publish', //only published articles
			'orderby' => 'date', // Order by date
			'order' => 'DESC', // Order in descending order (newest first)
			'suppress_filters' => false, // Let WPML apply its filters
			'lang' => ICL_LANGUAGE_CODE, // Ensure querying posts in the current language
			'fields' => 'ids', // Only retrieves post IDs
		);

you are using a "lang" argument for the WP_Query and this is a non-valid argument. There is no "lang" in WP_Query, so please remove it.

https://developer.wordpress.org/reference/classes/WP_Query/parse_query/

Look forward to your reply.

Thanks

August 26, 2024 at 5:08 am #16102324

coinQ

Hi,

Thank you for pointing that out. We apologize for the mistake. We mistakenly added the lang argument to the WP_Query while conducting some tests. We have now removed it, as it is indeed not a valid argument.

We appreciate your keen observation and quick response. Please let us know if there's anything else that needs our attention.

Thanks again for your support.

August 26, 2024 at 1:26 pm #16104748

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

sure, let us know after the tests how it goes.

August 27, 2024 at 6:55 am #16107594

coinQ

Hello,

We have completed the tasks you mentioned. All categories have been translated into all the languages we support, and we have also run the taxonomy synchronization option in the troubleshooting page.

However, we haven't noticed any significant improvement in performance. Could you please check the website again and provide your feedback?

Thank you for your continued support.

Best regards,
Vimal Roy

Taxonomy-translation-‹-Coin-Edition-—-WordPress (2).png
Troubleshooting-‹-Coin-Edition-—-WordPress.png
Troubleshooting-‹-Coin-Edition-—-WordPress (1).png

The topic ‘[Closed] Very slow queries’ is closed to new replies.