T
Thomas Jensen
Hi,
I'm replacing a VB application with a .NET application written in C#.
Previously I have been using the GetRows() function of ADO recordsets
quite extensively, because in the case of the old application it would
lower data retrival time several times.
I think the problem is that my data is stored in tables with a
relatively small row size, for instance tables containing currency
values (date/value pairs).
I will typically be selecting 100-1000 rows at a time.
Using an OdbcConnection/OdbcCommand/OdbcDataReader combination,
retrieving 500 records take as long as 1000 ms over a 100mbit/s switched
network.
I'm using OdbcDataReader.GetValues() to retrieve the values.
I have run the application with DevPartner Profiler, which confirms that
it is in the OdbcDataReader.GetValues() that the time is spend.
I'm currently programming for a MySQL server (4.0.14-nt) using MySql
ODBC driver 3.51, but I have experienced the same using a MSSQL server.
Performance Monitor shows up to 2000 packets/sec over the network during
processing, so I guess the problem arises from retrieving the records
one of a time.
Is there a way to force ADO.NET to buffer/prefetch data to avoid this
problem?
Simple program showing the problem:
OdbcConnection conn = new
OdbcConnection("DSN=mysql;DATABASE=idix_store;");
conn.Open();
string sql = "SELECT test_int, date_created FROM t_unit;";
OdbcCommand cmd = new OdbcCommand(sql, conn);
OdbcDataReader reader = cmd.ExecuteReader();
DateTime t1 = DateTime.Now;
while(reader.Read())
{
object[] vals = new object[reader.FieldCount];
reader.GetValues(vals); // <-- 400ms (500 rows),
// with GetRows this would be <50ms
}
DateTime t2 = DateTime.Now;
Console.WriteLine(t2-t1);
reader.Close();
I'm replacing a VB application with a .NET application written in C#.
Previously I have been using the GetRows() function of ADO recordsets
quite extensively, because in the case of the old application it would
lower data retrival time several times.
I think the problem is that my data is stored in tables with a
relatively small row size, for instance tables containing currency
values (date/value pairs).
I will typically be selecting 100-1000 rows at a time.
Using an OdbcConnection/OdbcCommand/OdbcDataReader combination,
retrieving 500 records take as long as 1000 ms over a 100mbit/s switched
network.
I'm using OdbcDataReader.GetValues() to retrieve the values.
I have run the application with DevPartner Profiler, which confirms that
it is in the OdbcDataReader.GetValues() that the time is spend.
I'm currently programming for a MySQL server (4.0.14-nt) using MySql
ODBC driver 3.51, but I have experienced the same using a MSSQL server.
Performance Monitor shows up to 2000 packets/sec over the network during
processing, so I guess the problem arises from retrieving the records
one of a time.
Is there a way to force ADO.NET to buffer/prefetch data to avoid this
problem?
Simple program showing the problem:
OdbcConnection conn = new
OdbcConnection("DSN=mysql;DATABASE=idix_store;");
conn.Open();
string sql = "SELECT test_int, date_created FROM t_unit;";
OdbcCommand cmd = new OdbcCommand(sql, conn);
OdbcDataReader reader = cmd.ExecuteReader();
DateTime t1 = DateTime.Now;
while(reader.Read())
{
object[] vals = new object[reader.FieldCount];
reader.GetValues(vals); // <-- 400ms (500 rows),
// with GetRows this would be <50ms
}
DateTime t2 = DateTime.Now;
Console.WriteLine(t2-t1);
reader.Close();