ci_sessions table is getting big - like 6M records and 90meg big - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12) +--- Thread: ci_sessions table is getting big - like 6M records and 90meg big (/showthread.php?tid=71072) |
ci_sessions table is getting big - like 6M records and 90meg big - zurtri - 07-02-2018 ci_sessions table is getting big - like 6M records and 90meg big Is there any problem with me just truncating the table? These are my settings in config PHP Code: $config['sess_driver'] = 'database'; I also note that my table did not have the primary key set: PHP Code: // When sess_match_ip = FALSE So my plan is to truncate the table (knock it to 0 records) and then add the primary key. Buuuuut - this is a production DB so I want to get the advice of the learned folks here before I commit such an act. Also why would my sessions in ci_sessions not be being cleaned up by the garbage collector? RE: ci_sessions table is getting big - like 6M records and 90meg big - skunkbad - 07-02-2018 Maybe a cron like this would help: PHP Code: /** RE: ci_sessions table is getting big - like 6M records and 90meg big - zurtri - 07-02-2018 Thank you. CI doesnt do auto garbage collection of the sessions table? RE: ci_sessions table is getting big - like 6M records and 90meg big - zurtri - 07-02-2018 By the way - thanks for that code - it works a treat! RE: ci_sessions table is getting big - like 6M records and 90meg big - dave friend - 07-02-2018 (07-02-2018, 05:50 PM)zurtri Wrote: Thank you. Yes, it is supposed to. In php.ini what are the values you have for session.gc_probability and session.gc_divisor? RE: ci_sessions table is getting big - like 6M records and 90meg big - zurtri - 07-02-2018 hmmm. both those values are 0 in my php.ini I guess that's the problem. RE: ci_sessions table is getting big - like 6M records and 90meg big - InsiteFX - 07-03-2018 These are the defaults for php.ini Code: session.gc_probability = 1 Try that. RE: ci_sessions table is getting big - like 6M records and 90meg big - dave friend - 07-03-2018 (07-02-2018, 08:12 PM)zurtri Wrote: hmmm. both those values are 0 in my php.ini Yup. That is a problem. InsiteFX offers a typical setting with session.gc_divisor = 1000 being the recommended "Production Value:. You could make it happen more often with Code: session.gc_probability = 1 The ratio of session.gc_probability to session.gc_divisor determines the chance that GC will occur not a hard and fast "once every 500 times". You might find this article interesting. The article suggests one reason why the values would be set to zero - so a cron job could periodically clean up. Looks like you don't' have that cron setup. RE: ci_sessions table is getting big - like 6M records and 90meg big - zurtri - 07-03-2018 Thank you dave |