• paip.sql索引优化----join 代替子查询法


    paip.sql索引优化----join 代替子查询法

    作者Attilax ,  EMAIL:1466519819@qq.com
    来源:attilax的专栏
    地址:http://blog.csdn.net/attilax

     select SQL_NO_CACHE  *,(
        SELECT
         LEFT (fecye, 1)
        FROM
         cyefenbyao   force index(i_hezi) 
        WHERE
         cyefenbyao.hezi = rit
      limit 1
       ) AS rit_cye
      FROM
       (
        select  
        max( gaopinzi.HEZI) hezi,
         LEFT (hezi, 1) AS lft,
         RIGHT (hezi, 1) AS rit
        FROM
         gaopinzi 
        WHERE
         LENGTH(hezi) = 6
     
          group by HEZI

            limit 30000
       ) AS t2 


    要1S,改成join  0.5S..


    select SQL_NO_CACHE 
    t2.*  ,LEFT (fecye, 1) as t1
    FROM
     (
      SELECT
       max(gaopinzi.HEZI) hezi,
       LEFT (hezi, 1) AS lft,
       RIGHT (hezi, 1) AS rit
      FROM
       gaopinzi
      WHERE
       LENGTH(hezi) = 6
      GROUP BY
       HEZI
      LIMIT 30000
     ) AS t2

    left join  cyefenbyao
    on cyefenbyao.hezi = t2.rit


     


     

  • 相关阅读:
    XML Schema (1)
    xml
    java输入输出流(内容练习)
    Java中I/O的分析
    java File类
    java中Map的用法(HaspMap用法)
    Git
    oracle安装分析
    博客第一天
    正则化 L1 L2
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3279838.html
Copyright © 2020-2023  润新知