I have a large .sdf
database file on windows mobile device that I need to query. The file has 40,000 records. I am trying to cut the time it takes to execute the query. Currently it is about 8 seconds, which is a lot of time for user to wait for the results.
At first I been using DataSet
, by establishing a SqlCeConnection
and filling adapter linked to dataset. Also tried to similar with DataTable
, performance results were almost identical. Using DataSet
or DataTable
finished query in about 8 seconds.
The last thing I tried was just using Reader()
. It give me a little better results, but only by half a second (query is finished in ~ 7.5 seconds).
string lastName;
lastName = "";
string connectionString = @"Data Source='/Path/To/MyDatabase.sdf' Max Database Size = 128; Max Buffer Size = 1024;";
string strSql = "SELECT LastName FROM employee_list WHERE LastName = 'Johnson'";
using (SqlCeConnection mConnection = new SqlCeConnection(connectionString))
{
mConnection.Open();
using (SqlCeCommand mCommand = new SqlCeCommand(strSql, mConnection))
{
using (SqlCeDataReader reader = mCommand.ExecuteReader())
{
while (reader.Read())
{
lastName = (string)reader["LastName"];
}
}
mCommand.Dispose();
}
mConnection.Close();
mConnection.Dispose();
}
Any ideas how can I make this faster?