Question

I have several different WP_Query within an index page of sorts, queried by category.

   $args1 = array(
   'post_type' => 'page', 'cat' => 3, 'meta_key' => 'indextitle', orderby => 'meta_value', 'order' => 'ASC'
    );
   $query1 = new WP_Query($args1); 

As you can see, I am sorting the query by the meta key "indextitle". I know that using Custom Fields for queries decreases performance quite a bit, but I was wondering if anyone knew if there was a similar performance hit when you choose to order your query by custom fields. In other words, does the orderby parameter have an impact on performance in any big way?

Était-ce utile?

La solution

Short answer: no

It does not have a big impact on performance. The WP_Query object constructs MySQL queries for you and does not do any of the sorting itself, which means that performance decrease would be caused by MySQL and not Wordpress.

If the table(s) you're quering are extremly large, it might be worth it to look into MySQL database/table optimization using techniques such as table indexing.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top