Take the 2-minute tour ×

I wanted to make a statistic for my website. So I could record user visits each day. Example:

   DAY   | USERS |
O1/01/13 | 256   |
O2/01/13 | 251   |

It is easy to do, but I am worried if it is a good idea to save it in DB? If I save in DB there would be 365 rows each year. Or should I save records in text file. But the problem is if I save in text wouldn't it be hard to get specific days data out? The reason I am thinking about text file is that I have never saved anything in text, so it would be something new to me. And also so if I have more than one year records I could just rename the text file.

share|improve this question
Save in Database. 365 rows are nothing for any db. even 365 * 100 are not a cause of concern –  Hanky 웃 Panky Jan 14 '13 at 17:15
I agree with Hanky Panky. Database engines can handle dozens of rows. –  Álvaro G. Vicario Jan 14 '13 at 17:19
btw... that was just sarcasm from @ÁlvaroG.Vicario - MySQL is designed to handle tables with millions of rows. –  ic3b3rg Jan 14 '13 at 17:40
add comment

3 Answers

up vote 1 down vote accepted

365 rows per year are really nothing. Even if you add more columns e.g. clicks, most viewed page etc. If you're still concerned about performance or so you can write a little cronjob to summarize the stats every year and write the results to another table.

share|improve this answer
Okay, thanks. I will do it that way then! –  ChrisMe Jan 15 '13 at 16:21
add comment

If you need transactional performance, database is better than using a flat text file.

share|improve this answer
add comment

A database can easily handle thousands of times the data this would use. A text file would be more trouble to work with than it's worth.

One alternative to consider is not storing this data at all and instead just running a query when you need it. This would also be easy for a database to handle and would allow for more flexibility with your statistics. This does require, however, that the data you're putting in that tables comes directly out of the database and not from some other source.

With how it is now, you would know how many users visited the site. If you got the data dynamically, you could add other criteria like time or unique visitors that wouldn't be available with your current setup.

share|improve this answer
add comment

Your Answer


