3

We building big Web Application and we use mysql, we want to make mysql database more fast. Some of us think if we will put message html body inside table and not inside text.txt in will make database heavy and not fast. Thanks,

*Part of main table that hold message: option 1:hold html message body inside database

message {
id (int)
subject (varchar)
body (text)
}

option 2: hold html message body inside body1.txt file

message {
id (int)
subject (varchar)
file_body_path (varchar)
}

*

2 Answers 2

2

If you:

  1. Don't need transactional control over the contents of your files and
  2. Only treat the files as an atomic entity (i. e. don't parse them, search for their content etc.)

, then you better store them out of the database.

The HTTP server will serve the disk-based files much faster to begin with.

Sign up to request clarification or add additional context in comments.

1 Comment

+1 I like your answer, all true , but see my 'answer' (more questions really)...
1

As Quassnoi correctly points out, the webserver will most likely be faster serving txt files than data from the DB ...

BUT: This only works if the webserver doesn't have to run any searches/queries against the DB to build the links between the TXT files.

Think of these use cases:

  • remove a text file
  • add a text file
  • add a link to a text file
  • remove a link from a text file
  • find a text passage within a text file.

each of these use cases will require your parsing the TXT file and maintaining all the needed links in the 'index-pages'. How will you do this in your content management system?

5 Comments

Why should body message file parsed?
@meyosef: that's what we should ask you, it's your system :) If you don't need parsing the message body or search for its contents you probably don't need to store it in a database as well.
@meyosef: IMO storing content in a DB vs a file system makes sense, if you need to maintain/market the links between those pages. No page is standalone, building index/landing pages (e.g the main stackoverflow.com page) is lot's of work if done manualy, but can be a breeze (well) with DB support. Ask yourself: Do I need the DB at all? If the answer is YES, then USE the DB for more!
the question also if database hold soo much data (message body) how its influence of all mysql database speed (because heavy database working worse then light database)
When you tried the db approach, was it too slow? StackOverflow and Wikipedia use this approach. Do they seem slow to you?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.