以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 数据处理慢 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=187952) |
-- 作者:creastzh -- 发布时间:2023/8/23 5:55:00 -- 数据处理慢 我通过表A、B对C表进行数据更新相关列,出现一个问题: 1 表A、B均大约数据行为12000行,表A更新表C仅用了1秒都不到,但表B却用了300多秒,查询条件两者均一致; 2 表A更改表C的2列数据,表B更改表C 5列数据 请帮我看一下是什么原因,谢谢! 代码如下: \'从Weekly和BK计划导入更新后的作业计划AutoUpdate_Schedule_From_WeeklyProductionSchedule_And_BK_INI_Production_Schedule SystemReady = False Try Dim dts As String = "Schedule" Dim dtm As String = "WeeklyMachineSchedule" Dim dtb As String = "INISecondarySchedule" If Not DataTables.Contains(dts) Then DataTables(dts).Loadfilter = "" DataTables(dts).Load End If If Not DataTables.Contains(dtm) Then DataTables(dtm).Loadfilter = "" DataTables(dtm).Load End If If Not DataTables.Contains(dtb) Then DataTables(dtb).Loadfilter = "" DataTables(dtb).Load End If Dim wo As String Dim op As Integer Dim drs As DataRow Dim drm As DataRow Dim i As Integer Dim t1 As Date = Date.Now Dim t2 As Date Dim t3 As TimeSpan For Each drm In DataTables(dtm).DataRows \'机加计划刷新Schedule If drm("Process_Competed") = False Then \'未完工项 wo = drm("WO") op = drm("OP") drs = DataTables("Schedule").Find("[WO]= \'" & wo & "\' and [C_Op]= " & op) If drs IsNot Nothing Then If drs("Plan_StartTime") <> drm("Adj_StartTime") Then drs("Plan_StartTime") = drm("Adj_StartTime") End If If drs("Plan_Endtime") <> drm("Adj_EndTime") Then drs("Plan_Endtime") = drm("Adj_EndTime") End If End If End If Next 1: t2 = Date.Now t3 = t2 - t1 Output.Show(t3.TotalSeconds) i = 0 Dim bDate As Date = Date.Today.AddMonths( - 1) \'上月当天 Dim drbs As List(Of DataRow) = DataTables(dtb).Select("[工序类别] not in (\'纵车\',\'5 Axis Grinder\',\'OutS - 纵车\',\'Mill\',\'EDM\',\'Puma\',\'Gun Drill\',\'OutS - Mill\') and [调整后_计划开工]>= #" & bdate & "#") Output.Show("Drbs.count:" & drbs.Count) For Each drb As DataRow In drbs \'BKSchedule刷新Schedule \'If drb("调整后_计划开工") > bdate Then wo = drm("WO") op = drm("OP") drs = DataTables("Schedule").Find("[WO]= \'" & wo & "\' and [C_Op]= " & op) If drs IsNot Nothing Then \'If drs("Plan_StartTime") <> drb("调整后_计划开工") Then drs("Plan_StartTime") = drb("调整后_计划开工") \'End If \'If drs("Plan_Endtime") <> drb("调整后_计划结束") Then drs("Plan_Endtime") = drb("调整后_计划结束") \'End If \'If drs("Status") <> drb("OPStatus") Then drs("Status") = drb("OPStatus") \'End If \'If drs("C_NeedHours") <> drb("计算需求尚须小时") Then drs("C_NeedHours") = drb("计算需求尚须小时")a \'End If \'If drs("Question_Des") <> drb("工序问题") Then drs("Question_Des") = drb("工序问题") \'End If i = i + 1 If i > 1000 Then
‘为测试运行时间跳出程序设置’ GoTo 2 End If End If \'End If Next 2: t2 = Date.Now t3 = t2 - t1 Output.Show(t3.TotalSeconds) Catch ex As Exception Output.Show("出现异常") End Try SystemReady = True 程序运行输出信息; 表A全部数据运行时间0.058804 表B 数据行数量:Drbs.count:12467 表B运行1000行数据花费的时间:24.6311707 |
-- 作者:有点蓝 -- 发布时间:2023/8/23 8:37:00 -- 看看:http://www.foxtable.com/webhelp/topics/2225.htm 另外如果这3个表都是在同一个数据库,考虑直接使用sql更新
|