M
marc hugon
Hello
I'm working on a batch program (command line utility), and I'm having
speed problems to read a lot of data from a database.
At first I thought it was what i was doing with the data that was slow
(and I can work on that), but I've encoutered another problem.
let's have a look at my current source code (removed lot of things) :
SqlConnection myConnection = new SqlConnection("Sql connect string");
myConnection.Open();
string mySelectQuery = "something a little fancy";
Console.WriteLine("Launch request "+DateTime.Now.ToLongTimeString());
myCommand = new SqlCommand(mySelectQuery,myConnection);
myCommand.CommandTimeout=600; //it may be long, so...
SqlDataReader myReader;
myReader = myCommand.ExecuteReader();
Console.WriteLine("Data work "+DateTime.Now.ToLongTimeString());
int counter = 0;
while (myReader.Read())
{
counter++;
}
Console.WriteLine(counter.ToString());
myReader.Close();
myConnection.Close();
Console.WriteLine("End "+DateTime.Now.ToLongTimeString());
and now : what I have on my console when executing this beauty :
Launch request 09:07:47
Data work 09:07:57
17742
End 09:09:37
1:40 minutes to read 17 742 rows of data ??????
how is this possible ??
how to make it work faster ?
any help appreciated
by the way, the sql request is returning 4 rows of the following types
: sqlsingle (real) (x2), string (varchar(7)), int (int(2))
I've tried using a dataset, it was a little slower.
one last information : the sql server is running on my development
computer, so no connexion problem between the command line and the
server....
Any idea, comment, critic, more than welcome
(by the way, I have other functions dealing with more than 500000
lines of data, the complete process takes more than 3 hours, that's
why I MUST find something faster)
Marc
I'm working on a batch program (command line utility), and I'm having
speed problems to read a lot of data from a database.
At first I thought it was what i was doing with the data that was slow
(and I can work on that), but I've encoutered another problem.
let's have a look at my current source code (removed lot of things) :
SqlConnection myConnection = new SqlConnection("Sql connect string");
myConnection.Open();
string mySelectQuery = "something a little fancy";
Console.WriteLine("Launch request "+DateTime.Now.ToLongTimeString());
myCommand = new SqlCommand(mySelectQuery,myConnection);
myCommand.CommandTimeout=600; //it may be long, so...
SqlDataReader myReader;
myReader = myCommand.ExecuteReader();
Console.WriteLine("Data work "+DateTime.Now.ToLongTimeString());
int counter = 0;
while (myReader.Read())
{
counter++;
}
Console.WriteLine(counter.ToString());
myReader.Close();
myConnection.Close();
Console.WriteLine("End "+DateTime.Now.ToLongTimeString());
and now : what I have on my console when executing this beauty :
Launch request 09:07:47
Data work 09:07:57
17742
End 09:09:37
1:40 minutes to read 17 742 rows of data ??????
how is this possible ??
how to make it work faster ?
any help appreciated
by the way, the sql request is returning 4 rows of the following types
: sqlsingle (real) (x2), string (varchar(7)), int (int(2))
I've tried using a dataset, it was a little slower.
one last information : the sql server is running on my development
computer, so no connexion problem between the command line and the
server....
Any idea, comment, critic, more than welcome

(by the way, I have other functions dealing with more than 500000
lines of data, the complete process takes more than 3 hours, that's
why I MUST find something faster)
Marc