データベースからストアド プロシージャを使用して 200MB 前後の大きなデータを取得します。以前は DataTable.Load() メソッドを使用して、このデータを DataTable に入力していました。しかし、パフォーマンスの問題が発生し、データのサイズが原因で DataTable が応答しません。
Using reader As DbDataReader = cmdHelper.ExecuteReader(CommandBehavior.CloseConnection)
Using rstResult As New DataTable()
rstResult.Locale = CultureInfo.InvariantCulture
rstResult.Load(reader)
Return rstResult
End Using
End Using
しかし、パフォーマンスを向上させるために DataReader を直接使用するようになりましたが、DatReader は接続アーキテクチャであるため、BusinessLogic が完了するまで DB 接続が開かれます。
Dim cnHelper As New DbConnectionHelper(_strDBConnection)
Dim cmdHelper As DbCommandHelper = cnHelper.CreateCommandHelper(strSP)
cmdHelper.Command.CommandType = CommandType.StoredProcedure
Dim reader As DbDataReader = cmdHelper.ExecuteReader(CommandBehavior.CloseConnection)
Return reader
したがって、BusineesLogic が実行されるまで DB 接続が開かれるため、DatReader を使用したくありません。
このシナリオで、DataReader を使用せずにパフォーマンスを向上させる方法はありますか?