zoukankan      html  css  js  c++  java
  • 关联的效率

     1 --A段
     2 ----------------------
     3 select so_d.*
     4        c_bf.FApproveState
     5   from sal_OrderList so_d
     6   left join bas_Bom bom_m 
     7      on (so_d.FMaterialKey = bom_m.FMaterialKey
     8         and so_d.FColorKey = bom_m.FColorKey)
     9   inner join com_BillInfo c_bf 
    10      on (bom_m.FFormKey = c_bf.FFormKey) 
    11         and (c_bf.FApproveState = 1)  
    12 
    13 --B段
    14 ----------------------
    15 select so_d.*
    16        c_bf.FApproveState
    17   from sal_OrderList so_d
    18   left join bas_Bom bom_m
    19   inner join com_BillInfo c_bf 
    20      on (bom_m.FFormKey = c_bf.FFormKey) 
    21         and (c_bf.FApproveState = 1)
    22      on (so_d.FMaterialKey = bom_m.FMaterialKey
    23         and so_d.FColorKey = bom_m.FColorKey)
     
    两段脚本达到的效果是一样的
     
    在查询分析器中显示计划的效果A段占用了70%的开销, B段占用30%开销,可见B段效率比A段高
     
     1 --A
     2 select wst.* 
     3   from com_MaterialWasteBook wst
     4     left join B_Material b_m on wst.FMaterialKey = b_m.FKey
     5     left join Color b_clr on wst.FColorKey = b_clr.FKey
     6     left join bas_Items b_sz on wst.FSizeKey = b_sz.FKey
     7   where b_m.FKey is not null
     8   
     9 ---B
    10 select wst.* 
    11   from com_MaterialWasteBook wst
    12     inner join B_Material b_m on wst.FMaterialKey = b_m.FKey
    13     inner join Color b_clr on wst.FColorKey = b_clr.FKey
    14     inner join bas_Items b_sz on wst.FSizeKey = b_sz.FKey
    15   

     上面两段

     查询开销

    A 占98%

    B 占2%

    但是实际执行时,在100多W的记录中A执行只需25秒左右,B需要50秒(结果执行多次)

  • 相关阅读:
    ps命令
    关于typedef的用法总结
    C#中正则表达式的使用
    调试与编译
    大端和小端
    64位程序内存之我看
    C/C++内存泄漏及检测
    内核中的 likely() 与 unlikely()
    do/while(0) c4127
    django+xadmin在线教育平台(六)
  • 原文地址:https://www.cnblogs.com/DKSoft/p/2134662.html
Copyright © 2011-2022 走看看