owatagal Posted September 10, 2005 Posted September 10, 2005 In terms of server load, what's the difference between calling information from a flat text file (using PHP's include() or readfile() functions) and putting the same information in a database and using SQL queries? I'm not thinking about complex information here -- just basic text like an about or copyright page might have. Quote
TweezerMan Posted September 10, 2005 Posted September 10, 2005 I would think that pulling the data through a MySQL query would put more load on the server and take longer to execute that just reading a plain file directly from the disk. MySQL table data is also stored in files on the disk. But to get that data and send it to a browser, the web server must open a connection to the MySQL server, submit a request (MySQL query) for the data, wait for the database server to process the query and retrieve the data, receive the query result from the MySQL server, and finally read the data from the returned query result. You have none of this overhead if you just read the text directly from a file on disk. There may be other reasons why you'd want this data stored in your database instead of in a disk file, but speed/resources wouldn't be one of them. Quote
Deverill Posted September 10, 2005 Posted September 10, 2005 If the data is part of a larger thing, for instance, "Hi _Jim_ you last logged in on _September 10_," then a database would be better than searching through 100,000 lines of a text file. If it is simply an include such as many sites have for copyright notices then a flat file containing only that info would be hugely better. SQL databases rule when you have to look up a piece of data from within 1000's but only after they get to a certain size - if you have 3 names a flat file would be quicker - if you have 300 then SQL may be... it all depends on the type of data. Quote
Madmanmcp Posted September 10, 2005 Posted September 10, 2005 I side with Jim here. This will depend mostly on the amount of data you have and the number of components in this "data". A flat file will handle a simple data file of one or two components very quickly, say name and sex. But when you have lots of components, name, age, sex, address, shoesize, etc...this is where a database wins hands down. A database uses indexing which speeds up the search and breaks the search down to just the component you want (sex), where a flat file will need to search every character. Quote
TCH-Rob Posted September 11, 2005 Posted September 11, 2005 I wonder what Freud would say about your last sentence, Bob. Quote
owatagal Posted September 12, 2005 Author Posted September 12, 2005 Thanks, guys! That confirms what I was thinking--but it's good to know why. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.