Hello,
I am running an update statement as part of an SQL query to update some values in a database. The database is quite large (around 230,000 records), so I appreciate updating such a large data set is going to take time, but the website currently hangs for what seems like 4-5 minutes before completing the updates, which is simply too long from a usability point-of-view.
Is it possible to do anything to speed up the update statement please?
I have included reference to the snippet of code containing the update statement below:
Dim intCounter As Integer
Dim strSQL4 As String
Dim myCommand4 As New MySqlCommand
If objDT.Rows.Count > 0 Then
For intCounter = 0 To objDT.Rows.Count - 1
objDR = objDT.Rows(intCounter)
strSQL4 = "UPDATE tbl_sales SET distance_temp = " & objDR("Distance") & " WHERE PostCode = '" & objDR("Postcode") & "'"
myCommand4.Connection = conn
myCommand4.CommandText = strSQL4
myCommand4.ExecuteNonQuery()
Next
End If
Many thanks!
I am running an update statement as part of an SQL query to update some values in a database. The database is quite large (around 230,000 records), so I appreciate updating such a large data set is going to take time, but the website currently hangs for what seems like 4-5 minutes before completing the updates, which is simply too long from a usability point-of-view.
Is it possible to do anything to speed up the update statement please?
I have included reference to the snippet of code containing the update statement below:
Dim intCounter As Integer
Dim strSQL4 As String
Dim myCommand4 As New MySqlCommand
If objDT.Rows.Count > 0 Then
For intCounter = 0 To objDT.Rows.Count - 1
objDR = objDT.Rows(intCounter)
strSQL4 = "UPDATE tbl_sales SET distance_temp = " & objDR("Distance") & " WHERE PostCode = '" & objDR("Postcode") & "'"
myCommand4.Connection = conn
myCommand4.CommandText = strSQL4
myCommand4.ExecuteNonQuery()
Next
End If
Many thanks!