Skip Navigation

[Resolved] Allocated memory size exhausted for wp_terms and wp_terms_relationship

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 6 replies, has 1 voice.

Last updated by Minesh 3 weeks ago.

Assisted by: Minesh.

Author
Posts
#2853336

jum

Hi,

For past few month we are facing this below issue.

Allowed memory size of 3145728000 bytes exhausted (tried to allocate 4096 bytes)
WordPress core
File: /wp-admin/class-wp-term.php
Line: 184

Allowed memory size of 3145728000 bytes exhausted (tried to allocate 20480 bytes)
WordPress core
File: /wp-admin/class-wp-term-query.php
Line: 1133

We are large database we do have more terms but we repair/optimized the table constantly and removed unwanted things. But still we are facing this issue.

Can you please guide us how to manage this issue

#2853339

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I'm not sure if Toolset involved here as it seems you have too many terms available and due to that you see the error you shared.

Where do you see the error you shared - is it in the backend or on frontend?

Can you please share problem URL and admin access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2853379

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I checked and I found that with the Grant post type you almost have twenty-four to twentry-six taxonomies assigned and that is a lot of content and if you may test without Toolset you may experince the same.

Regarding the screenshot you shared for the slow query, the first slow query is from WordPress code and that is becuase you have too many taxonnomies and second slow query belongs to "Plugin: wordpress-seo" we can not do much here due to the structure you have.

I've seen with few taxonomies you have only three or four terms added. There is a change to improve there but that will result is change of structure. Converthing such taxonomies where you have few terms to custom field.

#2853677

jum

Hi Minesh,

Ya I understand we do have lots of taxonomy and terms , we will try to reduce as much as possible. Meanwhile we constantly see this slow query

SELECT DISTINCT t.term_id, tr.object_id
FROM wp_terms AS t
INNER JOIN wp_term_taxonomy AS tt
ON t.term_id = tt.term_id
INNER JOIN wp_term_relationships AS tr
ON tr.term_taxonomy_id = tt.term_taxonomy_id
WHERE tt.taxonomy IN ('location', 'c....................................., 'horizon')
AND tr.object_id IN (274715, 217026, 220155, 217739, 277540, 277572, 218692, 293377, 43671, 293687, 292889, 292635, 293668, 293676, 293645, 250833, 194243, 293666, 102415, 286043)
ORDER BY t.name ASC

we repair and optimized the wp_terms, wp_terms_relationship and wp_term_taxonomy but still we see those slow queries , Can you please suggest what are the ways we can reduce this slow queries . Do i need to do reindexing? Can you please guide us on this.

Thanks in advance,

Regards
Kaviya

#2853842

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've added the "idx_term_taxonomy_object " index to the "wp_term_relationships" table:

ALTER TABLE wp_term_relationships
ADD INDEX idx_term_taxonomy_object (term_taxonomy_id, object_id);

Can you please check and see if the above solution help you to fix the issue.

#2853853

jum

Hi Minesh,

Thanks for looking into the issue. I still see the issue in query monitor

I checked the query monitor still i see the slow query
SELECT DISTINCT t.term_id, tr.object_id
FROM wp_terms AS t
INNER JOIN wp_term_taxonomy AS tt
ON t.term_id = tt.term_id
INNER JOIN wp_term_relationships AS tr
ON tr.term_taxonomy_id = tt.term_taxonomy_id
WHERE tt.taxonomy IN ('location', '....................................., '...izon')
AND tr.object_id IN (274715, xxxxxx, 286043)
ORDER BY t.name ASC

What I tried , I tried to change the index

ALTER TABLE wp_term_relationships
DROP INDEX idx_term_taxonomy_object,
ADD INDEX idx_object_term (object_id, term_taxonomy_id);

and index the wp_terms
ALTER TABLE wp_terms
ADD INDEX idx_name (name);

But still i see the same issue , please guide me on this

Thanks for the support

Regards
Kaviya

#2854211

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

This is not a Toolset issue actually. You have 23 taxonomies and even without Toolset if you query that many taxonomies with that many number of records it will have a issue.

I tried to display 15 results per page on your admin section and also try to display fewer columns on listing screen for the post type "Grant" and I can see it improved the result.
- hidden link