我一次插入一个包含 5000 条记录的块,一个块紧接着另一个块。这些命令在单独的 DLL 中创建,可以调用 4 个不同存储过程中的任何一个。是否有可能加快此速度的批量插入方法。目前,每条记录大约需要 1.5 MS,并且希望将其降低到大约 0.7 MS。
谢谢,
戴夫
Shared Sub WriteCMSMessagesToDatabase(ByVal myFacility As FacilityType, ByVal Commands As List(Of System.Data.OracleClient.OracleCommand))
Dim oracleConnection As New OracleConnection
Dim _Cmd As New OracleCommand
Try
Dim aStopWatch As New Stopwatch
Using oracleConnection
aStopWatch.Start()
oracleConnection.ConnectionString = myFacility.ConnectionString
_Cmd.Connection = oracleConnection
_Cmd.CommandType = CommandType.StoredProcedure
oracleConnection.Open()
_Cmd.Transaction = oracleConnection.BeginTransaction
For Each aCmd As OracleCommand In Commands
_Cmd.CommandText = aCmd.CommandText
_Cmd.Parameters.Clear()
For Each aParam As OracleParameter In aCmd.Parameters
Dim prm As New OracleParameter
prm = CType(DirectCast(aParam, ICloneable).Clone, OracleParameter)
_Cmd.Parameters.Add(prm)
Next
_Cmd.ExecuteNonQuery()
Next
_Cmd.Transaction.Commit()
aStopWatch.Stop()
End Using
Catch ex As Exception
End Try
End Sub