viewpoint-particle

Author Topic: Slow array query  (Read 122 times)

erezpaz

  • Newbie
  • *
  • Posts: 35
Slow array query
« 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

td

  • Tech Support
  • *****
  • Posts: 2024
    • WinBatch
Re: Slow array query
« Reply #1 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.)
"DON'T PANIC”
The Hitchhiker's Guide to the Galaxy, Douglas Adams


erezpaz

  • Newbie
  • *
  • Posts: 35
Re: Slow array query
« Reply #2 on: April 19, 2017, 11:33:23 am »
Hi

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

Thanks