欧美国产另类久热|951超碰伊人久久|伊人影视久久久久|色婷婷亚洲小电影|色东京热69XX|婷婷玖玖深爱网|加勒比东京热网站|无码A级毛片在线观看|一级a毛一级a看|中文字幕人妻欧美

一條sql語句變得非常慢的原因及其解決方法
來源:易賢網(wǎng) 閱讀:1051 次 日期:2014-10-08 09:06:56
溫馨提示:易賢網(wǎng)小編為您整理了“一條sql語句變得非常慢的原因及其解決方法”,方便廣大網(wǎng)友查閱!

現(xiàn)象:一條sql突然運行地特別慢.

select uidtable.column_value, first_name||' '

||last_name, company, job_title, upper(member_level),

upper(service_value)

from (select * from table(select cast(multiset

(select b from bbb)as taaa) from dual)) uidtable,member

where uidtable.column_value = member.login_id(+)

and member.site='alibaba' and member.site='test';

出錯原因:用戶增加了一個條件member.site=test,造成連接地順序變化了,原來地驅動表是uidtable(最多1024條記錄),現(xiàn)在變成了member表做驅動(600w條).所以這條語句變地巨慢.

但是既然是外連接,為什么連接地順序會改變呢?因為外連接地連接順序不是由cost決定地,而是由連接地條件決定地.發(fā)現(xiàn)執(zhí)行計劃如下:

-------------------------------------------------------

| id | operation | name | rows | bytes | cost |

--------------------------------------------------------

| 0 | select statement | | 1018 | 72278 | 8155 |

| 1 | nested loops | | 1018 | 72278 | 8155 |

| 2 | view | | 4072 | 69224 | 11 |

| 3 | collection iterator subquery fetch| | | | |

| 4 | table access full | dual | 4072 | | 11 |

| 5 | table access full | bbb | 41 | 287 | 2 |

| 6 | table access by index rowid | member | 1 | 54 | 2 |

|* 7 | index unique scan | member_site_lid_pk | 4 | | 1 |

-------------------------------------------------

為什么根本就沒有執(zhí)行外連接呢?問題出在member.site='test'這個條件上,因為對外連接地表加了條件,造成外連接失效.改為member.site(+)='test'后,問題徹底解決.

---------------------------------------------------

| id | operation | name | rows | bytes | cost |

-----------------------------------------------------

| 0 | select statement | | 1018 | 72278 | 8155 |

| 1 | nested loops | | 1018 | 72278 | 8155 |

| 2 | view | | 4072 | 69224 | 11 |

| 3 | collection iterator subquery fetch| | | | |

| 4 | table access full | dual | 4072 | | 11 |

| 5 | table access full | bbb | 41 | 287 | 2 |

| 6 | table access by index rowid | member | 1 | 54 | 2 |

|* 7 | index unique scan | member_site_lid_pk | 4 | | 1 |

更多信息請查看IT技術專欄

更多信息請查看數(shù)據(jù)庫
易賢網(wǎng)手機網(wǎng)站地址:一條sql語句變得非常慢的原因及其解決方法
關于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權所有:易賢網(wǎng)