Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Database vs file

 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys
I need to save a counter that can be updated (quite frequently) from many different servlets, i cannot let the data it holds get lost in case tomcat is shut down, so the only two options i see for that are saving the counter in a database (MySQL) or in a text file.

My question is as far as you know, what is faster for opening and writing into, the database or the text file?

Thanks, Joseph
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joseph,
A text file is likely to be faster. However, databases handle contention better. This may eat away at any time savings from the text file.

You could try both to see which works better for you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic