I'm currently migrating an old application that was built using VB6. The application is mainly used to process Data from an Access Database. I was using the DAO library to do all the work. I'm now migrating it to VB.net (using Visual Studio Express 2010) and starting to use the OleDb library but im facing a problem regarding speed. When i try to open and iterate a large table that is around 7 columns and 25 million rows (the datatypes are mainly doubles) from a network location it takes about 10 minutes. When i was using DAO it took me around 1.5 minutes to open the table and run through all the records. This is a major difference in speed in my application, i was not expecting that.
This is the procedure that im using to open that table:
Public Const ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
Public Const DataBasePath = "My DataBase Location"
Public BE As OleDbConnection = New OleDbConnection(ConnectionString & DataBasePath)
Public Sub OpenLargeTable
BE.Open()
Dim QueryExecute As OleDbCommand, DataSet as OleDbDataReader
Try
QueryExecute = New OleDbCommand("Select * From LargeTable Order By Field1, Field2, BE)
DataSet = QueryExecute.ExecuteReader() : DataSet.Read()
QueryExecute.Dispose() : QueryExecute = Nothing
Catch
'Error Handling
End Try
End Sub
I need to sort the table, and i was using an SQL statement with an Order By clause. I have found out that without the Order By it is very fast, it's just when i order the data that, in comparison with the DAO, it turns out to be really slow. I have tried to create a Query in the access database that sorts the records and then calling the query on the SQL statement in the OleDbCommand object but that doesn't help. My question is, is the OleDbDataReader the best method/object to open a large sorted dataset?
Thanks