最基本的是數(shù)據(jù)庫設(shè)計,一個糟糕的數(shù)據(jù)庫設(shè)計,當(dāng)記錄只有幾百幾千條的時候,可能看不出問題了,一旦達(dá)到幾萬幾十萬的時候,其速度就無法忍受了。 垃圾回收沒有問題,問題是你不通知垃圾回收器去回收那問題就大了,最突出是data connection 給你出兩個題,你看看能找出什么問題?
題一 SqlConnction conn = new SqlConnction SqlCommand myCommand = new SqlCommand("select * from aaa" ,conn) ; SqlDataReader sr ; try { conn.Open() ; sr = myCommand.ExecuteReader() ; while(sr.Read()) { //do something }
sr.Close() ; conn.Close() ; } catch(Exception e) { Console.Write("異常" + e.Message) ; } 看看有什么問題?
題二:
public int GetRecordCount() { //...計算結(jié)果 return result ; }
public void SomeMethod() { string strTemp = ""; for(int i = 0 ; i < GetRecordCount() ; i ++) { strTemp += "結(jié)果:" + SomeArray[i].ToString() + "\r\n" //do something } }
看看能看出什么問題來?
|