admin管理员组文章数量:1394065
I'm trying to search in two different post_type "places" and "events" but one parameter is about dates and places don't have this meta.
Also, event got 4 different dates : a start_date and end_date AND start_date_publish and end_date_publish who's here for determinate the moment when the event can be display on the site or on the search form results.
How can i make this query more light for searching on this two post type in one time ?
Here is the code that crashed the query because it's taking too much time to search :
(PS. Sry for this bad english)
array_push($meta_query_array, array(
'relation' => 'OR',
array(
array(
'key' => 'start_date',
'compare' => 'NOT EXISTS',
'value' => ''
),
array(
'key' => 'end_date',
'compare' => 'NOT EXISTS',
'value' => ''
),
array(
'key' => 'start_date_publish',
'compare' => 'NOT EXISTS',
'value' => ''
),
array(
'key' => 'end_date_publish',
'compare' => 'NOT EXISTS',
'value' => ''
)
),
array(
'relation' => 'AND',
array(
'key' => 'start_date',
'value' => $current_date,
'type' => 'DATE',
'compare' => '<='
),
array(
'key' => 'end_date',
'value' => $current_date,
'type' => 'DATE',
'compare' => '>='
),
array(
'key' => 'start_date_publish',
'value' => $current_date,
'type' => 'DATE',
'compare' => '<='
),
array(
'key' => 'end_date_publish',
'value' => $current_date,
'type' => 'DATE',
'compare' => '>='
),
)
));
本文标签: Heavy meta query causing SQL crash
版权声明:本文标题:Heavy meta query causing SQL crash 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744586266a2614214.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论