Large number of rows in a couple of tables creates performance issue

Laraship QuestionsCategory: TechnicalLarge number of rows in a couple of tables creates performance issue
equipetechnique asked 4 years ago
We've had our customer's site online for just over 4 months and we are experiencing serious performance issues (sometimes the site is simply no longer responsive). We've identified 3 tables which might be part of to the culprit: advert_impressions  (42M rows) advert_imp_visitor_details (41M rows) activity_log (12M rows) Every month we have to run some script to archive data and we are doing this without really knowing the overall impact to the app.  We also had to create a new index on advert_impressions to speed up queries again to mitigate a problem where the site was unresponsive. We ave basically two questions:
  1. Is there a setting which we would turn off in order to prevent populating these tables?
  2. If 1 is not possible, is there any side effect if we archive data on a weekly basis?  In other terms, are we going to see some features no longer working properly or broken because those tables are archived.
This situation puts our customer at risk. Thank you very much
1 Answers
laraship Staff answered 4 years ago
Hello, The three tables you just mentioned are just for  logging user activities and website visitor details, so if you think they are not needed you can  
  1. disable activity by adding this to the .env file and then clear config file

2. at Corals/modules/Advert/Classes/Advert.php disable lines 109 ~ 118

$impression = Impression::updateOrCreate([
'session_id' => session()->getId(),
'banner_id' => $banner->id,
'zone_id' => $zone->id,
'page_slug' => request()->headers->get('referer') ?? url()->current(),
], [
'impression_slug' => $bannerSlug,

$impression->visitorDetail()->updateOrCreate(['impression_id' => $impression->id], $this->getVisitorDetails());