WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: erezpaz on April 17, 2017, 11:11:12 AM

Title: Slow array query
Post by: erezpaz on April 17, 2017, 11:11:12 AM
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
Title: Re: Slow array query
Post by: td on April 17, 2017, 11:30:34 AM
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.)
Title: Re: Slow array query
Post by: erezpaz on April 19, 2017, 11:33:23 AM
Hi

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

Thanks