如何解释这个警告

时间:2017-07-19 08:04:42

标签: mysql

我正在使用MySQL 5.7.19并在以下脚本上运行explain之后:

explain select a.seller_id AS seller_id, 
       a.seller_name AS seller_name, 
       b.user_name AS user_name, 
       c.state AS state
from a
join b
join c
where((b.seller_name = a.seller_name) and
      (c.user_id = 17) and(b.user_id = 17) and
      (a.gmt_create between ((now() - interval 600 minute)) and ((now() + interval 600 minute)))) 
order by a.gmt_create;

以下是我收到的警告信息:

enter image description here

将其置于人类可读的形式:

select a.seller_id AS seller_id, 
           a.seller_name AS seller_name, 
           b.user_name AS user_name, 
           c.state AS state
    from a
    join b
    join c
    where((b.seller_name = a.seller_name) and
          (c.user_id = 17) and(b.user_id = 17) and
          (a.gmt_create between <cache>((now() - interval 600 minute)) and <cache>((now() + interval 600 minute)))) 
    order by a.gmt_create;

<cache>标签意味着什么?

1 个答案:

答案 0 :(得分:1)

引用manual

  
      
  • <cache>
  •   
     

表达式(例如标量子查询)执行一次,然后执行   结果值保存在内存中供以后使用。为了结果   由多个值组成,可以创建临时表   你会看到<temporary table>

这意味着,now() - interval 600 minute的计算只进行一次,结果将用于where子句检查的每一行。