I have problem with filtering posts by custom fields. On my page I have form with 15 conditions (radiobutons and inputs) and i'd like to filter with them my custom post type PROJEKT. My problem is with very slow query when i use so many meta keys. This is my code:
$posts = get_posts(array(
'numberposts' => -1,
'post_type' => 'projekt',
'post_status' => 'publish',
's' => $s,
'meta_query' =>
array(
'relation' => 'AND',
array(
'key' => 'technologia_wyszukiwarka',
'value' => $techs,
'compare' => 'LIKE'
),
array(
'key' => 'zabudowa_wyszukiwarka',
'value' => $styls,
'compare' => 'LIKE'
),
array(
'key' => 'garaz_wyszukiwarka',
'value' => $garazs,
'compare' => 'LIKE'
),
array(
'key' => 'mdm_wyszukiwarka',
'value' => $mdms,
'compare' => 'LIKE'
),
array(
'key' => 'powierzchnia_wyszukiwarka',
'value' => $pows,
'compare' => 'LIKE'
),
array(
'key' => 'kondygnacja_wyszukiwarka',
'value' => $konds,
'compare' => 'LIKE'
),
array(
'key' => 'ogrzewanie_wyszukiwarka',
'value' => $ogrzewanies,
'compare' => 'LIKE'
),
array(
'key' => 'liczba_pokoi_wyszukiwarka',
'value' => $pokojes,
'compare' => 'LIKE'
),
array(
'key' => 'inne_wyszukiwarka',
'value' => $innes,
'compare' => 'LIKE'
),
array(
'key' => 'kat_dachu_wyszukiwarka',
'value' => array($katods,$katdos),
'compare' => 'BETWEEN',
'type' => 'NUMERIC'
),
),
));
My query time WP_Query->get_posts
is something about 10s. But when I delete last conditions kat_dachu_wyszukiwarka
the time is shorter and acceptable 0.5 sec i checked it with Query Monitor. Unfortunately i need this field and few fields more. So my question is how can I do my query faster?