[wp-trac] [WordPress Trac] #29902: Allow no ORDER BY for comments in WP_Comment_Query

WordPress Trac noreply at wordpress.org
Thu Oct 9 11:30:27 UTC 2014


#29902: Allow no ORDER BY for comments in WP_Comment_Query
-------------------------+-----------------------------
 Reporter:  psycleuk     |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Comments     |    Version:  4.0
 Severity:  normal       |   Keywords:
  Focuses:  performance  |
-------------------------+-----------------------------
 The order by filters within WP_Query allow completely removing any order
 by appearing within the resultant posts database query, the same is true
 for the comments feed query in WP_Query. However it isn't the case for
 WP_Comment_Query.

 Within WP_Comment_Query the $groupby variable is checked and has the
 prefix 'GROUP BY ' added. What I propose is the same for $orderby.

 This would mean consistency between the two Query classes, and for those
 plugins that use the comments table for custom comment types, it'd allow
 removing any order by if the plugin deemed it unnecessary. For example
 with the latter requesting comments with a post_id, comment_type and
 user_id triggers a MySQL filesort even if the result is a single entry.
 Having no ORDER BY would skip the filesort yet have the same result.

 My attached patch simply duplicates what the existing $groupby does.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29902>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list