Link to home
Start Free TrialLog in
Avatar of LeeHenry
LeeHenry

asked on

Increasing load time of algorithm

My program is taking way too long to load, and I wanted to see if you experts knew of a better solution to my problem.
I have a program that takes in data dynamically. Sometimes it can load fast if the data it needs to read is small, but other times it needs to read and manipulate lots of data, and that is when it is taking forever. The function I use manipulate_data runs fast, it's processing all the queries and going through all the for loops that is taking so long. Is there another alternative? For example, would pushing the data on a stack run faster?

** I can have an infinite number of groups with each group having an infinite number of items in that group. **
**This is not the actual code. Just an example of what i'm doing**

1) Read in the amount of groups SQL query to database using RDO
2) Determine the amount of items in that group:
3) Manipulate all the data items in each group, then move on to the next group

For each GroupItem in the GroupCollection
   call manipulate_data
next

Sub manipulate_data()

For Each dataItem In colItems
     
         Sql = "SELECT * DataItemValues
         
         Set rsData = rdoConnect.OpenResultset(Sql, adOpenDynamic, adLockPessimistic)
     
         Do Until rsData.EOF
     
               DataItem.ManipulateData
               DoEvents
               Sleep 100

               'Update db with current state
               Select Case DataAction
                  Case 1
                     strSql = "Update Data1 set State = 1
                  Case 2
                     strSql = "Update Data2 set State = 2
                  Case 3
                     strSql = "Update Data3 set State = 3
               End Select

               rdoScriptConnect.Execute Sql
         
           
            rsData.Update
            rsData.MoveNext
       
      Loop
     
        rsData.Close
   
Next

End Sub


**By the way, I'm goint to be out of town this weekend. I'll check this again on monday**
Thanks in advance
SOLUTION
Avatar of David Lee
David Lee
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial