Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.7.0 introduced a slow query #1923

Open
c0ntax opened this issue Oct 22, 2024 · 0 comments
Open

4.7.0 introduced a slow query #1923

c0ntax opened this issue Oct 22, 2024 · 0 comments

Comments

@c0ntax
Copy link
Contributor

c0ntax commented Oct 22, 2024

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

  • Version used: 4.7.2
  • Browser Name and version: N/A
  • Operating System and version (desktop or mobile): Ubuntu 22.04.1-Ubuntu (Kernel 6.8.0-47-generic)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants