[wp-trac] [WordPress Trac] #14796: start_post_rel_link() makes 3 DB queries; too much for what it offers

WordPress Trac wp-trac at lists.automattic.com
Tue Oct 5 08:24:40 UTC 2010


#14796: start_post_rel_link() makes 3 DB queries; too much for what it offers
--------------------------+-------------------------------------------------
 Reporter:  demetris      |       Owner:                 
     Type:  defect (bug)  |      Status:  new            
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Performance   |     Version:  3.0.1          
 Severity:  normal        |    Keywords:                 
--------------------------+-------------------------------------------------

Comment(by demetris):

 Maybe I was wrong when I said {{{adjacent_posts_rel_link_wp_head}}} added
 4 queries, because I cannot reproduce that again.  Now I see it adding
 three (3) queries.

 The two are for post_date, as you said.  E.g.:

 {{{
 SELECT p.* FROM wp_posts AS p
 WHERE p.post_date < '2010-02-28 14:28:19' AND p.post_type = 'page' AND
 p.post_status = 'publish' ORDER BY p.post_date DESC LIMIT 1
 }}}

 {{{
 SELECT p.* FROM wp_posts AS p
 WHERE p.post_date > '2010-02-28 14:28:19' AND p.post_type = 'page' AND
 p.post_status = 'publish' ORDER BY p.post_date ASC LIMIT 1
 }}}

 The third extra query is like this:

 {{{
 SELECT `post_parent` FROM wp_posts WHERE ID = 534 LIMIT 1
 }}}

 Which seems to run a second time when
 {{{adjacent_posts_rel_link_wp_head}}} is on.

 (Here is how I check, in case I do something wrong:  I first comment out
 all four rel nav actions in default-filters.php.  Then I switch them
 individually and watch the queries with the SQL Monitor plugin.)

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14796#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list