Title: meta_query multidimensional array very slow
Last modified: August 20, 2016

---

# meta_query multidimensional array very slow

 *  [jrusi](https://wordpress.org/support/users/jrusi/)
 * (@jrusi)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/meta_query-multidimensional-array-very-slow/)
 * Hi,
    I have the following code:
 *     ```
       $args=array(
       'post_type'=>'custom_event',
       'meta_query' => array('relation'=>'OR', 
   
       array('key'=>'datefrom',
       'value'=>date("Y-m-d"),
       'compare'=>'>',
       'type'=>'DATE'),
       array('key'=>'datefrom2',
       'value'=>date("Y-m-d"),
       'compare'=>'>',
       'type'=>'DATE'),
       array('key'=>'datefrom3',
       'value'=>date("Y-m-d"),
       'compare'=>'>',
       'type'=>'DATE'),
       array('key'=>'datefrom4',
       'value'=>date("Y-m-d"),
       'compare'=>'>',
       'type'=>'DATE')
       ));
   
       $loop = new WP_Query( $args );
       ```
   
 * I have custom fields with dates of recurring event. I want to get all the upcoming
   events sorted by the closest date. But whenever I run this query the load on 
   the mysql server is very big and it takes few minutes to load the website. Any
   ideas why it is so heavy for the server? How can I sort the result based on the
   closest date?
 * Thanks 🙂

The topic ‘meta_query multidimensional array very slow’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [jrusi](https://wordpress.org/support/users/jrusi/)
 * Last activity: [14 years, 4 months ago](https://wordpress.org/support/topic/meta_query-multidimensional-array-very-slow/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
