Merge 3 list of objects

Options
I have 3 arrays with a common id that I want to merge in the most efficient manner. I am not able to use an addon or join as the biggest of these 3 arrays is cached and comes as a variable and not directly from the database - I guess we can't join/merge at this stage. Array 1 has 300+ items, and the others have 10+ items each. How do you propose I efficiently merge the 3? I can't cache Array 2 and Array 3.

Array1: List of all products sold
Array2: Quantities of some products ordered by this user
Array3: Size information of this user

PS: Running a loop on Array1 is the only solution I can think of. But have questions on that methods efficiency. 

Comments

  • Vikrant -1766326
    Options
      any comments?
  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options
    These are all pretty low counts. I would not worry too much about the looping. Seems like you would be able to do this in a non-optimized situation with 300*(10+10) = 6000 iterations, which should be trivially fast. You can introduce "break" logic to make the number of iterations go down, but I am not sure you'll even notice the change in performance because at this small scale, it will go quick enough.