Skip to content

Slow behaviour on admin-ajax requests #143

@rmccue

Description

@rmccue

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):

Screenshot 2024-02-20 at 11 30 51

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions