This question might look very basic to some, but please keep on, I have some good database programming for a while.
I have an algorithm that requires working on a website in PHP / MySQL. It displays some computations on an array of objects (this is the sequence of objects depending on their properties). In each iteration, the algorithm runs through the entire collection through all the time, accessing different data from different locations of the entire collection. To complete the algorithm several hundred walks must be done. The array comes from a database
I see that the simple solution is to take the result of a database query and create an object for each line of query, puts the object in an array and the array to my algorithm Passes on.
However, I am concerned about the efficacy of such a solution when I have to work with an array of thousands of items because whatever I do is the results of a query for memory that is mandatory Makes the mirror as a form.
On the other hand, it is wrong to question the database several times on every move of the algorithm.
So, I have a question - what is the right architecture solution for this kind of problem? Is it OK to mirror the query results in memory? If not, what is the best way to work with query results in such algorithms?
Thank you!
UPDATE : The closest problem I think is the ranking of search results by a search engine - I need to do something like every result is a line form of the database And all results of the set are considered when the rank is calculated.
The best way to go to memory - if you can scale it to complete, otherwise you can Your algorithm must be modified so that you can use the type of partition and conquer the type of approach - do something like merge sort.
Comments
Post a Comment