評價: 0 回應: 0 閱覽: 184
置頂

Slow in the Application, Fast in SSMS?

這是先前一個專案遇到的問題
當時是用gridview去呼叫一個sqldatasource
因為邏輯擴充的關係,所以將SQL script改寫成stored procedure

於是問題就發生了,那個網頁超慢,有多慢呢
大約是不到一秒變成一分鐘那麼慢
利用SSMS直接執行SP也是一秒不到
後來乾脆改寫成塞到Data table 然後塞gridview還是慢

當時的狀況是
1.sqldatasource 呼叫SQL command 快
2.sqldatasource 呼叫sp 慢
3.SQL command 產生Datatalbe慢
4sp 產生Datatalbe慢

於是找遍了關鍵字去搜尋,最後就如同標題一樣,打出了
Slow in the Application, Fast in SSMS
其實已經是自暴自棄了
就找到了Parameter Sniffing issue!!!
跟大家分享一下

http://www.sommarskog.se/query-plan-mysteries.html

http://blogs.technet.com/b/mdegre/archive/2012/03/19/what-is-parameter-sniffing.aspx

https://www.simple-talk.com/sql/t-sql-programming/parameter-sniffing/

 

 

 

會員登入 (先登入會員才能回覆留言喔!)

Facebook留言