authorship
authorship copied to clipboard
Slow behaviour on admin-ajax requests
I'm working with a customer who is experiencing slowness on admin-ajax requests, which appears to be at least partially attributable to Authorship.
For example, on a query-attachments
action (sorted by highest impact):
The specific query here doesn't seem too strange:
{
"post_id": "1234",
"query": {
"post_mime_type": "image",
"paged": "1",
"posts_per_page": "80",
"orderby": "date",
"order": "DESC"
},
"action": "query-attachments"
}
However, this appears to be inefficiently querying the authors for these posts; there are 99 queries total, so approx 1 query per post (plus static overhead), where each query is:
SELECT DISTINCT t.term_id
FROM wp_4_terms AS t INNER JOIN wp_4_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN wp_4_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id
WHERE tt.taxonomy IN ('authorship') AND tr.object_id IN (4321)
ORDER BY tr.term_order ASC
Are you seeing the same issue on the main Posts listing screen in the admin area (at wp-admin/edit.php
)? I just checked another site and it is indeed performing a query to fetch the terms in the authorship
taxonomy once for each post ID.
My understanding is that when fetching a list of posts, the list of terms for its taxonomies should be fetched at once and cached, but that is not happening.
Looks like it, but harder to tell there. We're also hitting another bug with that which means the performance of the page is terrible (hierarchical post list tables are ungood)
e.g. 10% of page load (but this isn't a particularly slow one):
This does have one query per author as well (50 queries to list 10 posts)