asp.net code executes very fast on development while very slow on production
I have the following code to build a large string. it runs well on my
development pc, about taking 2 seconds to complete all tasks, but when I
put them on production server, it will take 10-20 seconds depending on
something unknown. The time is calculated from TimePoint1 to TimePoint2.
BTW: abstractTable.GetWordCountInList(listID) just contains one line:
return 100;
All other functions on production server work ok, except for this one.
Oracle DB server and Web Server are on the same machine, and the query
returns about 5000 records. Product server's data is same as the
development server.
public const string WordXMLItemTemplate = @"<S I=""{0}"" W=""{1}""
L=""{2}"" F=""0"" P=""0"" />";
int totalCounter =0;
int wordCounter = 0;
int listID = 1;
OracleConnection wordLibConn = ConnectionManager.GetNewConnection();
wordLibConn.Open();
try
{
OracleCommand comm = new OracleCommand();
comm.Connection = wordLibConn;
comm.CommandText = "Select WordID from WordTable Order By Lower(Word)
ASC";
OracleDataReader dataReader = comm.ExecuteReader();
try
{
// TimePoint 1
while (dataReader.Read())
{
totalCounter++;
wordCounter++;
wordXML = wordXML + string.Format(WordXMLItemTemplate,
totalCounter, dataReader[0].ToString(), listID);
if (wordCounter % abstractTable.GetWordCountInList(listID) == 0)
{
wordCounter = 0;
listID++;
}
}
}
finally
{
dataReader.Close();
}
}
finally
{
wordLibConn.Close();
}
// TimePoint 2
I suffered from the problem for months, thanks a lot for any advice.
No comments:
Post a Comment