I am using a lot of custom post types (CPTs) with custom meta and so far I have been using queries like the below, to get for example all events in CountryX that happened in 2014:
<?php global $paged; $curpage = $paged ? $paged : 1; $args = array( 'numberposts' => -1, 'post_type' => 'event', 'orderby' => 'event_date', 'meta_key' => 'event_date', 'order' => 'DES', 'posts_per_page' => 50, 'paged' => $paged, 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'event_date', 'compare' => '<=', 'value' => 20141231, ), array( 'key' => 'event_date', 'compare' => '>=', 'value' => 20140101, ), array( 'key' => 'event_country', 'compare' => 'LIKE', 'value' => 'CountryX', ), ), ); $the_query = new WP_Query( $args );
I am concerned about the time, RAM and CPU processes that such queries take so I have started reading about custom SQL queries (https://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query).
It is still not clear to me if switching to a custom query will improve speed or there is no improvement whatsoever in my case.
Additionally, since I am just starting with SQL, would appreciate any help in how to start writing queries like the above (with multiple conditional statements).
edit: While we are at it, is using
LIKE a good idea to query custom meta fields that have texts and/or arrays?
Thanks in advance