Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Increasing load time of algorithm

Posted on 2004-10-01
2
Medium Priority
?
198 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:LeeHenry
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 76

Assisted Solution

by:David Lee
David Lee earned 1000 total points
ID: 12204222
Three questions.

1.  Have you done any testing to see which part of the code is causing the slowdown?
2.  What does DataItem.ManipulateData do?
3.  Why the Sleep 100?
0
 
LVL 3

Accepted Solution

by:
redfordb earned 1000 total points
ID: 12205007
1) At first glance, the sleep shouldnt be there.
2)Instead of using the DO UNTIL LOOP do the following...

   Add two new variables ie NumOfRecords and RecordLoop

   After your open set NumofRecords to the records in the dataset ie
   'Open dataset
   NumOfRecords = rsData.recordcount
   RecordLoop = 0
   While Not (RecordLoop > NumOfRecords)
        'Put your processing here...
         RecordLoop = RecordLoop + 1
   Wend
  'Continue with your code

3) Before and after each stage in your loop add a write to an output file (like a log). Then run the program and analyze the log for delays.
4) If the long delays are justified, look at putting in a progress bar or something so the user knows something is happening. It makes the wait more bearable.

   
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question