-2

I have a website (Laravel + Mysql on top of 'dedicated server') where I save all the pages that every user sees for reporting. My site is visited 10,000 times a day and this statistic makes the database size bigger after a few months. now 'visits' table occupied 85% of whole database!

Is there a way to do this that is the best way possible?

Behzad
  • 47
  • 1
  • 8
  • 2
    Why are you storing all of the results in the database? You should be consolidating them after x amount of months. Keep only the most recent months worth of entries and consolidate the rest into a totals table. I don’t see why you’d need to keep every exact record for that for 6 months worth of visits. – Savlon Sep 12 '21 at 11:38
  • 1
    Also, you have the same info in logs, havent you? Then you can use tools like [Loki](https://grafana.com/oss/loki/) or [ELK stack](https://www.elastic.co/log-monitoring) or many others and just stop clogging production database. – Jan 'splite' K. Sep 13 '21 at 06:48

1 Answers1

2

I have not encountered this problem before, but I think its better to take the logging with this much of heavy load out of primary database, you can move it to a file system or logging services (read this).

Or you can have job (background process) to remove the logs that you don't need Like logs from a month ago, this will help db a little bit.
Read some best practices

Amir Daneshkar
  • 771
  • 3
  • 9