[wp-trac] [WordPress Trac] #7247: get_pages specific use case
optimization
WordPress Trac
wp-trac at lists.automattic.com
Sat Jul 5 06:57:58 GMT 2008
#7247: get_pages specific use case optimization
--------------------------+-------------------------------------------------
Reporter: DD32 | Owner: anonymous
Type: defect | Status: new
Priority: normal | Milestone: 2.7
Component: Optimization | Version: 2.6
Severity: normal | Keywords: has-patch
--------------------------+-------------------------------------------------
At present, When using get_pages() with $child_of > 0 & $hierarchical ==
false, *every* post is called from the database, pages which are not a
child of it are then filtered out.
This patch moves the child_of filtering to the SQL query for when
heirarchial is not requested, This reduces the number of SQL results.
If hierarchical is true, Then every page is still called up as previous,
this is mearly an optimization for the one specific case
Maintains 100% back compat from what i can see.
Eg:
{{{
code:
$pages = get_pages( array('child_of' => 14, 'hierarchical' => 0) );
before:
"SELECT * FROM wp_posts WHERE (post_type = 'page' AND post_status =
'publish') ORDER BY post_title ASC"
after:
"SELECT * FROM wp_posts WHERE (post_type = 'page' AND post_status =
'publish') AND post_parent = 14 ORDER BY post_title ASC"
}}}
--
Ticket URL: <http://trac.wordpress.org/ticket/7247>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list