Slow to close MySqlDataReader

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply

Slow to close MySqlDataReader

Post by hrjun » Mon 15 May 2006 02:49

Hi there!

I have codes below...

Code: Select all

void doFetch()
	MySqlConnection dbConn; // make the connection via direct mode.
	MySqlCommand dbCmd = new MySqlCommand("select * from my_tbl", dbConn);
	MySqlDataReader dbReader = dbCmd.ExecuteReader();
	try {
		int limit = 10;
		while(dbReader.Read()) { // If the dbReader has 10000 records.
			// do something...
			if (limit++ > 1000) // break here!
	} finally {
		if (dbReader != null)
			dbReader.Close(); // VERY SLOW!!!!

When I tested those codes with CoreLab's Oracle Provider, the dbReader closed immediately.
But CoreLab.MySql.MySqlDataReader was not.
(I'm not sure but it seems to read all the records in Close() or Dispose().)

I tested it with the 'DataReader' in ~CoreLab/MySQLDirect.NET2/Samples
on Windows XP SP2, MySQL4.x and CoreLab.MySql3.30.10.0.

How can I solve this problem?

Thanks in ahead.

Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Mon 15 May 2006 08:59

This happens because MySql database retrieves all the records from the table. We can't change MySql database server.

Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Tue 16 May 2006 14:44

Try to use ExecutePageReader method.

Post Reply