Re: [問題] 連結MS SQL產生系統效能低落
※ 引述《SinclairShen.bbs@ptt.cc (SinclairShen)》之銘言:
你的bottleneck看起來出在你的web server機會比較大
你所謂3G記憶體吃完,指的是吃掉SQL Server的3G
還是你呼叫SQL那台機器的3G ?
還有一次要傳送20+萬筆資料,也會佔據大量網路頻寬
所以你這個需求有很多地方都會出現bottleneck
基本上很少需求會需要一次把20萬筆資料一次都撈出來
因為人眼一次觀看20+萬筆資料是一點意義都沒有的
建議你前端程式可以做paging(分頁),減少你一次撈那麼多的資料拖垮兩邊效能
那我猜或者你可能想拿這20+萬筆來做運算
如果是的話,請在SQL Server算完再把結果回傳出去即可
還有如果一定需要一次撈那麼大的資料量,那你不應該採用DataSet
應該使用DataReader即可
其實還有很多調整效能的方法
例如Table可以做index,還有你如果覺得Table資料量那麼大,可以做Partition
甚至從硬碟下手,提高IO速度都可以大幅提高效能
> 能否請教各位大大一個問題...
> 目前有一個期貨的資料庫(future2),
> 裡面有一個資料表(futureData),
> 共有八百萬筆資料,
> 在select時就會把電腦3G的記憶體吃完,
> 也嘗試過改成以"每日"來select資料(每日大約有20萬筆資料),
> 也是會很快的把記憶體吃完,
> 最後系統會變得非常慢…
> 把資料放到DataSet之後,已經有把連資料庫的部份close和dispose了,
> 那所占的記憶體空間怎麼沒被釋放掉?
> 謝謝
> source code:
> DataSet enDataSet = new DataSet();
> enDataSet.Tables.Add("future_data");
> public void conDB_future(string strSql)
> {
> string connStr = "Data Source=localhost;
> database=future2;uid=sinclair2;
> pwd=222;Connection Timeout=3600;pooling=false;";
> SqlConnection conn1 = new SqlConnection(connStr);
> conn1.Open();
> SqlDataAdapter conAdapter1 = new SqlDataAdapter(strSql, conn1);
> conAdapter1.Fill(enDataSet, "future_data");
> conAdapter1.Dispose();
> conn1.Close();
> conn1.Dispose();
> }
> public void button1_Click(object sender, EventArgs e)
> {
> string strSql = "";
> strSql = "select * from futureData ";
> //
> //strSql = "select * from futureData where 交易日期='" + sData + "'";
> //
> conDB_future(strSql);
> }
--
◥◣ │◢ 我說拔辣!!◣╭─────────╮ ◢香蕉!!◣ \ ◢◤ˋ
ˋ ˊ▊ ●◤◥ ◤│ IP:140.123.174.1▂▃▅▆▇ ◥ ◤◥ ● ▊" ˊ
" " ▋╯ ▁▃ DN:bala.twbbs.org│ ╰◢◤ "
∵ ∵▌▂▃▄▅▆▇█ ╰─────────╯《中正資管‧芭樂的故鄉》 ▋!
!◢◤ FR: 114-45-174-120.dynamic.hinet.net ◢◤ ◢
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章