views:

116

answers:

2

Hi, 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  A: 

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.

Quassnoi
+1 I like your answer, all true , **but** see my 'answer' (more questions really)...
lexu
Thanks you very much!
Yosef
+1  A: 

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?

lexu
Some nice points here too, +1
Quassnoi
Why should body message file parsed?
Yosef
@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.
Quassnoi
@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!
lexu
thank you very much
Yosef
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)
Yosef
When you tried the db approach, was it too slow? StackOverflow and Wikipedia use this approach. Do they seem slow to you?
Seun Osewa