【发布时间】:2019-02-08 15:41:30
【问题描述】:
我使用插件 WP Job Manager 为我的网站编写了一个自定义的相关空缺查询。使用查询监视器时,我一直认为查询非常慢(5 秒以上)。
我已经实现了查询缓存,但这需要查询至少运行 1 次。
是否可以进一步加快这样的查询速度?
$location = get_post_meta($id, '_job_location', true);
$category = get_post_meta($id, 'job_category_wo', true);
$args = array(
'post_type' => 'job_listing',
'numberposts' => 5,
'meta_query' => array(
'relation' => 'OR',
array(
'key' => '_job_location',
'value' => $location,
'compare' => '='
),
array(
'relation' => 'AND',
array(
'key' => '_job_location',
'value' => $location,
'compare' => '='
),
array(
'key' => 'job_category_wo',
'value' => $category[0],
'compare' => 'LIKE'
)
)
)
);
$postslist = get_posts( $args );
【问题讨论】:
标签: mysql wordpress performance