I need to update about ten lines of code on my front page every day. I want to do this with a php include statement but I am not sure what is the best to gather the data. I can code it in one of two ways: MySQL or parse if off a text file uploaded to server. My question is Which is quicker, a text file or a call to MySQL? I want my home page to load fast.
I would expect that the database would be faster. Either way, it probably wouldn't take very long with just a few queries, though.
Yes, it really depends on how many data is at the text file and how complex is it to parse. Further i would take in account; if you do not need a database at all at your site then setting up or pay a database just for such a little feature is wasting money. I would prefer flat files in that case.
Completly depends on the amount of data that you need to display. However, even if you don't need to display alot of data, instead of a textfile, you should use XML which is much more structured.
If the data is very less then u can use text file other wise database is the best option. For the later expansions database will be the best choice.
Depends what you mean by parsing the code - this HTML or Jscript that's going to be stored? If so then I'd imagine the text file would be vastly faster in most cases especially for 10 lines as imagine the difference. - On the one hand you've got a database where PHP needs to make a connection (authentication etc)., wait for the database to perform the query, process the query in the database and then send all the data back via the API so that PHP can sort it into variables. - On the other PHP makes a system call to say "read X file" which is usually a pretty optimised operation especially for regular requests (file-caching and such). The OS finds the file, passes it back as a stream to PHP which drops it into a variable and bingo there you've got it. Reading off a disk is very, very fast for a server and some might even keep the file in memory cache as well as caching the fact that it exists so even quicker. Forgot to add - the above assumes you're using something like MySQL as the database. It might be a bit quicker with SQLLite or similar as they're more flat file, but still not sure it'd really improve load times vs just reading from a disk. Trev
Both are almost equally the same. The difference is that once you get more data it's easier to manage that data with a database rather than a file system. So for the long run, go with the MySQL database.
database access is faster than txt access, but this is important only for major data if you only have 1kb of data, stick to txt or how someone before said, xml