I wish to then add static information connected with string secrets to any or all of my pages. The person PHP pages apply certain of this information strained with a query string. The better method of add these details? Produce a 100K (or bigger if more information is required later) PHP file by having an connected array or add some other DB table with this particular info and query that?
The very first solution involves loading the 100K file each time even when I personally use only a few of the info on the present page. The 2nd however adds an additional database call towards the rendering of each and every page.
The less pricey if you will find a lot of pages? Loading a PHP file or making an additional db call?
Unless of course it's proven to actually be considered a bottleneck (whether it is such as the php file or querying the database), you need to pick the option that's best maintainable.
My prediction is that it's the second item. Store it inside a database.
Storing it inside a database is a far greater plan. Using the database you are able to have better data constraints, easier mix reference along with other data and make strong associations. You might need that at this time around, but it is an infinitely more flexible solution ultimately.
What's the data employed for? I am wondering when the data you'll need might be saved inside a session variable/cookie once it's drawn in the database which may permit you to not query the db around the rendering of each and every page.
Should you leverage a PHP file then utilizing APC as well as other opcode cache will mitigate performance concerns as the PHP files are only loaded every time the file changes.
However, as others have noted, a database is the greatest spot to store these items because it is much simpler to keep (this ought to be your priority to start with).
Getting made certain easy maintenance along with a working application, in the event you need a performance boost then generally recognized practice is always to cache this static data within an in-memory key/value store for example memcached. This provides you with rapid use of your static values (for many demands).
I would not refer to this as information "static".
In my experience, it is simply a routine call to obtain dome information in the database, among other calls being designed to assemble whole page. Things I am missing?
And That I do accept Dennis, all optimizations ought to be according to real needs and profiling. Otherwise it's effect might be opposite.
If you wish to utilize some caching, envisage to implement Conditional GET for the entire page.