Which is better resource wise, MySQL or File?

13 replies
-------------------------------
#file #mysql #resource #wise
  • Profile picture of the author Terry Crim
    [DELETED]
    {{ DiscussionBoard.errors[7386314].message }}
  • Profile picture of the author SteveSRS
    also consider that writing to flat files is very error sensitive like this. (write 1 thing wrong all your data might be corrupt). Its much safer in a db..
    and really the 'speed' you win is almost nothing (unless you have other sites / parts access the db a lot).

    I won't recommend flat files..
    {{ DiscussionBoard.errors[7388091].message }}
    • Profile picture of the author Terry Crim
      [DELETED]
      {{ DiscussionBoard.errors[7388112].message }}
      • Profile picture of the author FirstSocialApps
        Originally Posted by Terry Crim View Post


        In your view then the speed increase from not having to query the database over and over for little bits of data is negligable and not worth the time messing with flat files?
        I think what he is saying is that things like deleting a line or adding a line in the middle of a flat file are inherently prone to corruption if the code is not perfect. Also as he said flat files ARE faster. but is it worth the effort.

        It would help if you described what data your saving and what you plan to do with it.
        {{ DiscussionBoard.errors[7390767].message }}
        • Profile picture of the author SteveSRS
          exactly what FirstSocialApps said..

          Originally Posted by Mark Brian View Post

          MySQL eats a significant amount of RAM even on standby in your server so only use it if you actually need a database.
          WRONG, it uses a portion of the ram on standby however this is 'not significant' unless you have a server with less then 128mb or RAM (which is not very smart any-way). It also doesn't EAT Ram as when Mysql isn't being used RAM usage will NEVER grow. Further more this RAM usage can be specified in the config file so thus is completely up to yourself.

          Originally Posted by annaharris View Post

          Flat files are are always going to be faster and it's simple that Small amount of data has requires less space so file can naturally run faster and on other hand if data is large then it needs more space so it will be slower.
          Nonsense 'Flat files are are always going to be faster', you clearly have no idea what you are talking about. This has to be most wrong statement I've ever seen. Even if you are only talking in the situation with 'super small amounts of data in the files' you are dead on WRONG. Think about this situation:
          class a.php access some file b.txt on the server which has some data inside (couple lines 1 or 2 kb).

          Due to concurrent visitors the class is initiated like 5 - 30 times (30 concurrent visitors on medium site is not weird around peek times, popular sites have of course much more). That means the file is access that many times at the same time.

          This is 'OK' when it is just reading the file data.. however if certain actions also write to this file what is going to happen you think?

          It ALL gets screwed up (data) + operations are going to be slowed down HUGELY.

          Really: NEVER use flat files with data you need to write for end-user operations.

          Avoid it for reading more then just 1 word or perhaps a never changing list of options (one per line or something) which you want to display (in that case still dump to use it in .txt file in that case just put it in an array in a php file!)

          If you need database a-like functionality but you don't have mysql installed use sqlite.
          {{ DiscussionBoard.errors[7390828].message }}
  • Profile picture of the author Mark Brian
    MySQL eats a significant amount of RAM even on standby in your server so only use it if you actually need a database.
    Signature

    {{ DiscussionBoard.errors[7388234].message }}
  • Profile picture of the author annaharris
    Flat files are are always going to be faster and it's simple that Small amount of data has requires less space so file can naturally run faster and on other hand if data is large then it needs more space so it will be slower.
    {{ DiscussionBoard.errors[7388759].message }}
  • Profile picture of the author phpg
    If you have a connection to MySQL opened for some other needs by your script anyway, or if your script is going to write more than just a few times during its' runtime, or if you have many concurrent scripts running and writing at the time, MySQL will probably be faster and less resource intensive.

    In other words, when the volume is high, MySQL is faster. And when the volume is low, it doesn't really matter. This of course applies to data writing, not reading.
    {{ DiscussionBoard.errors[7391319].message }}
    • Profile picture of the author JacobS
      You also have to consider scalability. Rewriting/testing code can end up being a major drain, so depending on whether or not you'll need it to be something that can be scaled up, you might be better off going with SQL queries even if this approach uses a bit more resources at the moment.
      {{ DiscussionBoard.errors[7398127].message }}
  • Profile picture of the author ritahersom
    If you want to do complex query and searching of data quite frequently then according to me mysql is better compare to file
    {{ DiscussionBoard.errors[7397257].message }}
    • Profile picture of the author Terry Crim
      [DELETED]
      {{ DiscussionBoard.errors[7403423].message }}
  • Profile picture of the author Terry Crim
    [DELETED]
    {{ DiscussionBoard.errors[7403429].message }}
  • Profile picture of the author SteveSRS
    Hey,

    The big story you were describing on how to use it sounds more like NoSql (and it alternatives) however if you just want to use it 'in a few places' in your apps you might be better using flat text files..

    However still in case of you just want to use it in a 'few places' have a look at this:
    MySQL Query Cache

    It does basically what you are looking for and its a lot easier then the whole system you are going to need to write to handle everything that you want.
    {{ DiscussionBoard.errors[7407968].message }}
  • Profile picture of the author wizwebtechno
    Its always better to use dbms like mysql than the flat file when you want process and fetch data properly. So go for mysql
    {{ DiscussionBoard.errors[7412391].message }}
  • Profile picture of the author rising_sun
    Banned
    MySql is the best and fast in between them,
    but the problem is connection error and MySql crush ,
    otherwise it is professional.
    {{ DiscussionBoard.errors[7412760].message }}
  • Profile picture of the author KriiV
    Small files are faster; however, MySQL DB's are scalable and still extremely fast.
    {{ DiscussionBoard.errors[7413350].message }}

Trending Topics