zoukankan      html  css  js  c++  java
  • SQL 语句中left join 与join 条件放置位置,进而影响SQL语句的执行效率的问题

      最近遇到SQL语句链接时 条件位置  是否影响SQL执行效率的问题:

     1、 

    select  top 100  a.*  from ( select * from tableA where <...过滤条件...>) a
    left join (select *  from  tableB where <...过滤条件...>) b on  a.tableBid=b.id  

    2、

    select  top 100  a.*   from tableA   a
     join    tableB  b on  a.tableBid=b.id   and a. <...过滤条件...>  and b. <...过滤条件...>

    自己感觉  1 的查询速率会快,  因为 是先缩小数据源再 关联的;比先关联之后再过滤 扫描读取数据少;

    以下是SQL语句 执行结果:

     就SQL 语句返回的结果来上说,先缩小数据源的大小 再关联 这种情况  执行时间短,扫描表也少

  • 相关阅读:
    spi详解
    spi协议
    C语言break,return
    通信协议
    传输层
    网络层
    数据链路层
    物理层
    无线通信
    cpu设计过程
  • 原文地址:https://www.cnblogs.com/ITyueguangyang/p/14452693.html
Copyright © 2011-2022 走看看