欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

mysql 语句 优化 有大用 有大大用

select count(n.nid) as count from node n inner join content_type_kefuchat kefuchat on n.nid=kefuchat.nid inner join content_field_genzong_time genzong_time on n.nid=genzong_time.nid inner join content_field_time field_time on n.nid=field_time.nid inner join content_field_is_baoming is_baoming on n.nid=is_baoming.nid inner join content_field_is_dingjing is_dingjing on n.nid=is_dingjing.nid where n.type='kefuchat' and field_time.field_time_value >='2017-02-28 16:00:00' and kefuchat.field_suozaixiaoqu_value in ('wz','xq','hd') and genzong_time.field_genzong_time_value is null and kefuchat.field_chat_status_value='complete' and ((is_baoming.field_is_baoming_value is null or is_baoming.field_is_baoming_value='否' ) and (is_dingjing.field_is_dingjing_value is null or is_dingjing.field_is_dingjing_value='否' ) ) and n.nid>1

为什么最大加上 and n.nid>1  速度非常快呢?

我用 explain 分析 (加 and n.nid>1   和 不加 and n.nid>1 的语句 ) 没有什么区别,都是下面的这个图的结果


image.png

普通分类: