publishpress / PublishPress-Authors

PublishPress Authors is the best plugin for adding many authors to one WordPress post. You can create multiple authors, co-authors and guest authors.
14 stars 8 forks source link

4.7.0 introduced a slow query #1923

Open c0ntax opened 1 month ago

c0ntax commented 1 month ago

Expected Behavior

When displaying a post with an author's custom avatar, the code to generate the page should be performant

Current Behavior

get_custom_avatar() now uses attachment_url_to_postid(). This function searches the postmeta table by both meta_key and meta_value. Meta_value() cannot be indexed because it's a longtext so you end up with an inefficient query that can run on a page multiple times. It was adding anywhere between 0.8s and 1.5s to every page that displayed an author on my site.

Possible Solution

  1. Introducing caching
  2. Add a filter get_custom_avatar filter so that users's can introduce their own caching or do things differently
  3. Roll back the code to 4.6.x?

Steps to Reproduce (for bugs)

  1. Have a site with lots of posts and lots of metadata per post
  2. Render an author with a custom avatar on a page
  3. Look the Query Monitor tool bar light up

Context

I just want an author with a custom avatar on a page.

Your Environment