views:

51

answers:

3

What's better? I want to share a script where some data (4 ints (between 0 and 2000) and a string (length up to 200)).

Should I store them in files or in a MySQL database? I use normally databases, but in this case are files also not that bad (to handle).

The problem is that there are partial in one day over 100.000 inserts. That are some million in a few days. Could handle MySQL so huge data in under 1 second? Or is it better to create for each day a seperated file?

PS: I want to have a big user base who could use it, so files are probably better?

+5  A: 

You need a database for this type of thing. Databases handle concurrency much better than files. Mysql can handle 100k inserts a day no problem. You will probably want aggregate the data and move to another table for reporting. Since indexes slow inserts your table will need to carefully designed and cleaned up on a regular basis.

Byron Whitlock
A: 

I agree with Byron - you need a database. Unless you only have one simultaneous user a DB is generally better than lots of bugs ;-)

Without a better understanding of the use case it's hard to propose the correct solution, but maybe you could generate a new MySQL table for each day or week? As long as you don't ever need to query the data as a whole, that'll work. And you can easily zip up the directory and push it somewhere else for archiving purposes.

Benjamin Cox
+2  A: 

Have you considered SQLite as a good inbetween?

It has all the database functionality you would probably need, but it has all the portability of flatfiles and it's easy to create a new one and archive the old ones.

Judging by the sound of your project it might be a perfect fit.

thismat