有人知道如何加快查询速度吗
$events_arr = array(
\'post_type\' => \'event\',
\'post_status\' => \'publish\',
\'posts_per_page\' => 100,
\'orderby\' => array( \'event_start\' => \'ASC\'),
\'meta_query\' => array(
\'relation\' => \'OR\',
array(
\'key\' => \'event_start\',
\'compare\' => \'=\',
\'value\' => $queried_date,
),
array(
\'relation\' => \'AND\',
array(
\'key\' => \'event_end\',
\'compare\' => \'>=\',
\'value\' => $queried_date,
),
array(
\'key\' => \'event_start\',
\'compare\' => \'<\',
\'value\' => $queried_date,
),
),
),
);
字面意思:
return events that starts today, or those that already begin but did not end yet.In reality this query walks thru all events 并过滤掉其中一些。问题是,这是一个极其缓慢的过程,将来还会变得更糟。
理想的结果是,如果查询只直接获取给定数量的事件。因为现在,无论我想要多少或很少的事件,它总是得到所有并在之后处理它们,或者看起来像这样。在我的情况下,每次都会得到所有实际的1700个事件。。(如果我们不将缓存带入帐户)
谢谢你的帮助