Slow array query

Started by erezpaz, April 17, 2017, 11:11:12 AM

Previous topic - Next topic

erezpaz

Hi

I got a two dimension array with 50 on 150 elements.
I created a for function to query data and place in in a new array to present in report view dialog:
         
for i2w = FromH to nRmax1-1
   for j2w = 0 to nCmax1-1
      LastRunFromEDRDB = EDRDBArr[i2w,0]
      RTOfromEDRDB = EDRDBArr[i2w,32]
      LastResfromEDRDB = EDRDBArr[i2w,42]
   next
   if LastRunFromEDRDB == LastTimeRunDDMMYYFromI then
      break
   else
      LastResfromEDRDB = "No data"
      RTOfromEDRDB = "No data"
   end if
next

It take up to 1 minute for the function to complete.
I know that working  with Array is very fast.
Am i doing something wrong?

Thanks

td

Why are you using a nested loop?  You are only accessing three columns of each row and not every column of every row.  Your script as written has 7500 loop iterations when it only needs 150 (assuming 150 rows with 50 columns per row.)
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

erezpaz

Hi

Yes, that solved it, it is much quicker now...

Thanks