I created a custom post type with a custom taxonomy. I have about 1500 posts all of which are assigned to some sort of taxonomy term…some being assigned to 200+ terms.
I noticed that from the dashboard, it takes an extremely long amount of time to view the custom post types, most of the time resulting in a 504 Gateway Time-Out.
Querying these post from the front-end is just fine and I have no issues with that.
It’s my understanding that when the dashboard is trying to view these custom post types, it’s trying to pull all the information assigned to each post, before it shows everything.
I do have this WP install set to be able to use as much memory as needed (memory_limit = -1), as I was researching, some said it may be memory related.
Is there something i can do to increase the performance of this query …maybe not load all the taxonomy term relationships of a post until you’re editing the post?
Errors after increasing WP_MEMORY_LIMIT
from 1Gb to 2Gb:
WordPress database error: [MySQL client ran out of memory]
SELECT t.*, tt.*, tr.object_id FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('locations') AND tr.object_id IN
WordPress database error: [Lost connection to MySQL server during query]
SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN
WordPress database error: [MySQL server has gone away]
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month FROM wp_posts WHERE post_type = 'services' ORDER BY post_date DESC
The CPT and taxonomy terms are created via plugin. I was able to lessen the query by adding the following to my plugin:
As of currently, I have 700+ posts tied to 1500+ taxonomy terms and everything is working great. The posts are showing up almost instantaneously.
** I did not write this code. Someone I work with directly, who is not part of the WordPress Answers community, provided the code — maybe it can help someone else, or someone else can possibly expand off it to make it more efficient. **