[wp-trac] [WordPress Trac] #10886: WordPress should not unnecessarily query posts at page load

WordPress Trac wp-trac at lists.automattic.com
Fri Oct 2 01:10:15 UTC 2009


#10886: WordPress should not unnecessarily query posts at page load
--------------------------+-------------------------------------------------
 Reporter:  junsuijin     |       Owner:  junsuijin                       
     Type:  defect (bug)  |      Status:  new                             
 Priority:  normal        |   Milestone:  2.9                             
Component:  Optimization  |     Version:  2.8.4                           
 Severity:  normal        |    Keywords:  has-patch, tested, needs-testing
--------------------------+-------------------------------------------------
 For plugins like BuddyPress, with pages that have no WordPress post
 content, a query for posts at load time creates unnecessary overhead. I've
 tested this patch (with WordPress MU) and it removes 3 queries on all
 pages when the 'NO_QUERY' constant is defined. A very quick scan of page
 load times also suggests about 20% in time savings on average.

 Other plugins like shopping carts and any others that needn't query the
 WordPress posts table can benefit from this as well.

 My previous means of achieving this effect was to simply return null to
 the 'posts_request' filter, which removes only 2 queries per page.

 The devised method uses suggestions from azaozz and sivel, and allows for
 setting the definition of 'NO_QUERY' using the 'init' action hook. It also
 still allows for further querying of the posts at a later point if
 necessary.

 I welcome further suggestions about the patch, and any other ways this
 could be accomplished more effectively.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/10886>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list