Text storage, database or files?


Something that's bugged me on and off for a while now is optimising my text (e.g. blog posts) storage on my sites.

Way back in the day my host limited MySQL databases to 100mb. So I scripted my sites to store a filename rather than the body of text. The file was then grabbed and outputted using whatever PHP functions came to hand at the time. The alternative obviously is storing the text directly in the database.

With database size limits now gone, I'm asking the question which is less resource hungry?

Using Files

Once the database query is returned, PHP has to go and get the file and its contents. Finding and returning the file makes expensive disk reads.

Using the Database

The database simply returns more data, but with database servers often not residing on the local machine and more data having to be transferred across the network.

Which is Optimal?

I keep reading about bottlenecks first appearing with queries to a database, so it makes sense to me that reducing the load there would be preferred. But using a database and then storing a bulk of data in the file system seems a little like defeating the point of using a database to me.

All thoughts, much appreciated :)

Comments? Tweet me @mealybar, smoke signals, or homing pigeon, or something :)