<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        mysqlexplain:innerjoinanalysis;&amp;lt;eq_ref)betterthan&amp_MySQL

        來源:懂視網 責編:小采 時間:2020-11-09 20:12:33
        文檔

        mysqlexplain:innerjoinanalysis;&lt;eq_ref)betterthan&_MySQL

        mysqlexplain:innerjoinanalysis;<eq_ref)betterthan&_MySQL:MySQLexplain bitsCN.com explainselect t.order_sn, t.cust_code, ti.tms_order_other_info_id, sp.province_name, sc.city_name, sr.region_name, st.town_name, t.buyer_addressfrom tms_order t inner join tms_order_other_info ti on t.tms_order_id=t
        推薦度:
        導讀mysqlexplain:innerjoinanalysis;<eq_ref)betterthan&_MySQL:MySQLexplain bitsCN.com explainselect t.order_sn, t.cust_code, ti.tms_order_other_info_id, sp.province_name, sc.city_name, sr.region_name, st.town_name, t.buyer_addressfrom tms_order t inner join tms_order_other_info ti on t.tms_order_id=t
        MySQLexplain

        bitsCN.com explain
        select t.order_sn, t.cust_code, ti.tms_order_other_info_id, sp.province_name, sc.city_name, sr.region_name, st.town_name, t.buyer_address
        from tms_order t inner join tms_order_other_info ti on t.tms_order_id=ti.tms_order_id
        inner join crm_cust c on t.cust_code=c.cust_code
        left join sb_province sp on t.buyer_state=sp.province_code
        inner join sb_city sc on t.buyer_city=sc.city_code
        inner join sb_region sr on t.buyer_area_id=sr.region_code
        left join sb_town st on t.buy_town = st.town_code
        where t.created_office = 'VIP_NH' and c.created_office='VIP_NH'
        #and (t.cust_code='NHLDP053' or 'NHLDP053' = '' )
        and t.is_autopicked in (1, 3)
        and t.order_sub_type = 11
        and t.order_status in (1,2)
        and t.cust_code is not null
        and t.add_time > date_sub(now(),interval 10 day)
        and c.is_showpoint = 1 and ifnull(ti.has_matchpoint, 0) = 0

        order by t.cust_code, t.created_dtm_loc limit 500

        /

        上面的tms_order等表,是千萬級數量數據.

        上面的執行效率正常,執行計劃也正常,

        而把left join sb_province sp 換成 inner join sb_province sp 后:: 效率就直線下降

        explain
        select t.order_sn, t.cust_code, ti.tms_order_other_info_id, sp.province_name, sc.city_name, sr.region_name, st.town_name, t.buyer_address
        from tms_order t inner join tms_order_other_info ti on t.tms_order_id=ti.tms_order_id
        inner join crm_cust c on t.cust_code=c.cust_code
        inner join sb_province sp on t.buyer_state=sp.province_code
        inner join sb_city sc on t.buyer_city=sc.city_code
        inner join sb_region sr on t.buyer_area_id=sr.region_code
        left join sb_town st on t.buy_town = st.town_code
        where t.created_office = 'VIP_NH' and c.created_office='VIP_NH'
        #and (t.cust_code='NHLDP053' or 'NHLDP053' = '' )
        and t.is_autopicked in (1, 3)
        and t.order_sub_type = 11
        and t.order_status in (1,2)
        and t.cust_code is not null
        and t.add_time > date_sub(now(),interval 10 day)
        and c.is_showpoint = 1 and ifnull(ti.has_matchpoint, 0) = 0
        order by t.cust_code, t.created_dtm_loc limit 500

        /

        sp表的type就變成ALL了,并且執行效率直線下降,why?????

        是因為inner join的方式 ,優化會執行的過程是這樣的:

        ->先range analysis 分析所有表的大概記錄數,其中sp表是幾十行數量級的也就是最小的,它就會作為距動表,放在最左邊,決定了sp表的順序

        ->計算全表掃描與使用索引的IO成本,決定sp表的訪問方式,是用不用索引,用什么類型的索引,在這里它是用ref索引,

        ->根據這個排序,窮舉分析他們的執行計劃成本,可見sp表數據太小,先join它成本是最小的,(也可以理解為優化器在inner join中一般不用數據量太小的表的索引)

        另外:

        發現除了st表使用eq_ref索引,其他的表卻使用ref索引, 就是說,st表的掃描比其他表的快...why???

        是因為,sp表所引用的索引,它是一個uniqe key,

        (eq_ref:從該表中會有一行記錄被讀取出來以和從前一個表中讀取出來的記錄做聯合。)

        (ref: 該表中所有符合檢索值的記錄都會被取出來和從上一個表中取出來的記錄作聯合。)

        (ref_or_null: 這種連接類型類似 ref,不同的是mysql會在檢索的時候額外的搜索包含null 值的記錄。這種連接類型的優化是從mysql4.1.1開始的,它經常用于子查詢。)

        效率 eq_ref > ref > ref_or_null

        bitsCN.com

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        mysqlexplain:innerjoinanalysis;&lt;eq_ref)betterthan&_MySQL

        mysqlexplain:innerjoinanalysis;<eq_ref)betterthan&_MySQL:MySQLexplain bitsCN.com explainselect t.order_sn, t.cust_code, ti.tms_order_other_info_id, sp.province_name, sc.city_name, sr.region_name, st.town_name, t.buyer_addressfrom tms_order t inner join tms_order_other_info ti on t.tms_order_id=t
        推薦度:
        標簽: mysql than ref
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top 主站蜘蛛池模板: 久草福利资源网站免费| www一区二区www免费| 亚洲国产精华液网站w| 亚洲乱码中文论理电影| 麻花传媒剧在线mv免费观看 | 国产亚洲成在线播放va| 在线a人片天堂免费观看高清| 精品亚洲456在线播放| 日韩精品免费在线视频| 无码乱人伦一区二区亚洲一 | 无码国产精品一区二区免费式影视| 久久久亚洲欧洲日产国码是AV | 亚洲精品字幕在线观看| 在线看片免费人成视频久网下载 | ww4545四虎永久免费地址| 亚洲中文无韩国r级电影| 久久国产亚洲精品| 午夜免费福利在线| 另类专区另类专区亚洲| 国产日韩成人亚洲丁香婷婷| 华人在线精品免费观看| 亚洲色欲或者高潮影院| 女人18毛片a级毛片免费| 污视频网站在线观看免费| 在线免费观看中文字幕| 特级aa**毛片免费观看| 亚洲人成色7777在线观看| 永久免费精品影视网站| 国产福利免费观看| 亚洲成a人无码亚洲成av无码 | 亚洲精品无码不卡在线播HE| 99在线免费观看视频| 国产成人精品亚洲日本在线 | 免费一级全黄少妇性色生活片| 中文字幕精品无码亚洲字| 啦啦啦完整版免费视频在线观看| 亚洲av无一区二区三区| 四虎影视免费在线| 99精品免费视频| 亚洲第一区二区快射影院| 亚洲午夜福利717|