PDA

View Full Version : Thoughts on reading/writing to file vs. db


dank
04-13-2001, 03:55 PM
A lot of programs I've looked at store their user configurable variables in a table in the database (MySQL).[nbsp][nbsp]That seems somewhat inefficient, since it requires querying the database every time you want to read in the variables.[nbsp][nbsp]However, it's also simpler and more reliable than writing the variables to a file (which can then be included at any time), considering differing write/owner permissions from server to server.

Does anyone have any opinions on whether one method is more efficient than the other, and by how much?[nbsp][nbsp]How much overhead goes into including a small "text" file?[nbsp][nbsp]I would assume very little, but...

Dficient

PaulKroll
04-13-2001, 04:23 PM
The file is going to be so much more efficient it's not even funny. 10 times. 50 times. For that operation, it's positively lightning fast.

However, the permissions issue can be a pain, if you're making this for folks using many different environments... maybe using a Perl/SetUID script for setting the vars? (That still sounds highly serve dependant. :( )

dank
04-13-2001, 05:07 PM
I figured as much...[nbsp][nbsp]Does that 10-50x guesstimate hold true even if a single query is done for all the variables in the table, then used throughout the files until a new page is loaded?[nbsp][nbsp]Obviously, a separate query whenever a variable is needed would be server suicide.

My preference is to keep it all PHP (in case you hadn't guessed :) ), as the fewer things to explain installation-wise the better.[nbsp][nbsp]But Perl seems better geared toward setting permissions.[nbsp][nbsp]It looks like I may have to continue searching for a one-size fits all solution, although I'd be surprised to find that it exists...

Dan

PaulKroll
04-13-2001, 05:29 PM
Does that 10-50x guesstimate hold true even if a single query is done for all the variables in the table, then used throughout the files until a new page is loaded?
Yes.

And to your next question, no, I don't just watch for your messages and then comment on them, although it may look that way at times. :)

dank
04-13-2001, 05:47 PM
I hadn't thought to ask that question, although that's one more thing to not have to cross off my yet to be written list...[nbsp][nbsp]Your input is always very much appreciated, so feel free to continue answering any questions, whether or not I've asked them.[nbsp][nbsp]:)

Dan

Rich
04-13-2001, 07:05 PM
It looks like I may have to continue searching for a one-size fits all solution, although I'd be surprised to find that it exists... Yes, you're right, there isn't one. Each approach you learn should be considered like tools in a toolbox. Use the one that is most appropriate for the task.

Rich

dank
04-13-2001, 07:12 PM
Point well taken, but I'm not sure how it applies to the question of a way to set file permissions regardless of server configuration...[nbsp][nbsp]No matter how big the toolbox is, if at least one of the available tools doesn't work for the job, a bigger toolbox ain't gonna aleviate the problem.

Dan