Question for those in the know:
Background:
A few weeks back when reading some postings on a PHP/MySQL board I read a post where a person talked about a three-tier architecture where the first tier was the db queries an such with the results being put into arrays and setting variables. The middle tier was the actual guts (programming) of the solution and the third tier was the user interface.
Now, after several redesigns and rebuilds of my learning-site (is there any other way?) I am actually beginning to implement this architecture!
Question(s):
Just how much more efficient (processor utilization, time to produce pages, server load, etc.) is it to store query results in an array and then manipulate (query, read from, etc.) the array instead of requerying the db?
As an illustrative example, I forsee a table in my solution to have ~15 fields and 1200 records in it. If I need to search this table to pull a dozen records out of it which would be more efficient: doing the query directly or having some PHP code to search through an array which holds all 1200 records?
Is there a break even point? I can see clearly how a small table with ~12 records is best queried once, the result put into an array and using the array from there. But how about the 1200 I used in the example above? Is there a rule of thumb such as # of times I expect to read the array (or do the query) during a session or hits on the site or ???
Many thanks once again for your thoughts and comments!
EZ


LinkBack URL
About LinkBacks




Reply With Quote

Bookmarks