Foxtable(狐表)用户栏目专家坐堂 → 数据处理慢


  共有1075人关注过本帖树形打印复制链接

主题:数据处理慢

帅哥哟,离线,有人找我吗?
creastzh
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:238 积分:1749 威望:0 精华:0 注册:2023/1/11 7:15:00
数据处理慢  发帖心情 Post By: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



 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106803 积分:543216 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2023/8/23 8:37:00 [只看该作者]

看看:http://www.foxtable.com/webhelp/topics/2225.htm

另外如果这3个表都是在同一个数据库,考虑直接使用sql更新

 回到顶部