this question may seem too simple for some, but please keep this in mind, some time has passed since I was engaged in decent database programming.
I have an algorithm that I need to program in PHP / MySQL to work on a website. It performs some calculations iteratively on an array of objects (it evaluates objects based on their properties). At each iteration, the algorithm passes through the entire collection a couple of times, accessing various data from different places throughout the collection. The algorithm needs to perform several hundred iterations. The array comes from the database.
The direct solution that I see is to take the database query results and create an object for each row of the query, put the objects in an array and pass the array to my algorithm.
Nevertheless, I am interested in the effectiveness of such a solution when I have to work with an array of several thousand elements, because what I do essentially reflects the results of the query into memory.
On the other hand, making a database query a couple of times at each iteration of the algorithm also seems wrong.
So my question is: what is the right architectural solution for such a problem? Is it possible to reflect the results of a query in memory? If not, is this the best way to work with query results in such an algorithm?
Thank!
. , , - - . , , .