[wp-trac] Re: [WordPress Trac] #7457: Sticky Posts
WordPress Trac
wp-trac at lists.automattic.com
Mon Aug 4 05:43:30 GMT 2008
#7457: Sticky Posts
----------------------------------+-----------------------------------------
Reporter: ryan | Owner: anonymous
Type: defect | Status: new
Priority: normal | Milestone: 2.7
Component: General | Version:
Severity: normal | Resolution:
Keywords: sticky posts blessed |
----------------------------------+-----------------------------------------
Comment (by DD32):
Adding menu_order to the type_status_date key and ordering it the same as
the query removes the need for a filesort:
{{{
EXPLAIN SELECT SQL_CALC_FOUND_ROWS wp_posts . *
FROM wp_posts
WHERE 1 =1
AND wp_posts.post_type = 'post'
AND (
wp_posts.post_status = 'publish'
)
ORDER BY wp_posts.menu_order DESC , wp_posts.post_date DESC
LIMIT 0 , 10
id select_type table type possible_keys key key_len
ref rows Extra
1 SIMPLE wp_posts ref type_status_date_order
type_status_date_order 124 const,const 49 Using where
}}}
Key:
{{{
ALTER TABLE `wp_posts` DROP INDEX `type_status_date` ,
ADD INDEX `type_status_date_order` ( `post_type` , `post_status` ,
`menu_order` , `post_date` , `ID` )
}}}
It appears that unless the order by keys are in the order index in the
same order that they're used, MySQL cannot rely on the key for the sort.
--
Ticket URL: <http://trac.wordpress.org/ticket/7457#comment:15>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list