[wp-trac] [WordPress Trac] #41281: attachment_url_to_postid results in very slow query

WordPress Trac noreply at wordpress.org
Sat Jul 14 06:03:45 UTC 2018


#41281: attachment_url_to_postid results in very slow query
------------------------------+------------------------------
 Reporter:  Takahashi_Fumiki  |       Owner:  (none)
     Type:  enhancement       |      Status:  new
 Priority:  normal            |   Milestone:  Awaiting Review
Component:  Database          |     Version:  4.9
 Severity:  normal            |  Resolution:
 Keywords:                    |     Focuses:  performance
------------------------------+------------------------------

Comment (by samvthom16):

 I have been facing the same issue as I have close to 40k posts and
 equivalent number of items in the media library. Lot of plugins like Yoast
 Seo use the function attachment_url_to_postid() quite often. This causes a
 slow query because of the huge database.

 I agree with @markjaquith on caching the results as these URLs don't
 change that often. The function can use transient variables instead of
 querying the posts table.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/41281#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list