数据库中的 Yii2 会话存储,行太多?表现? [英] Yii2 Session Storage in DB, too many rows? Performance?

查看:30
本文介绍了数据库中的 Yii2 会话存储,行太多?表现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用 yii\web\DbSession 进行会话存储,我当前的表中有 33,000 行.

I just started using yii\web\DbSession for session storage, my current table has 33,000 rows in it.

我需要所有这些记录吗?我在使用它们吗?我应该设置某种删除所有旧记录的实现吗?

Do I need all these records? Am I using them? Should I be setting up some sort of implementation that deletes all old records?

推荐答案

看来,你的项目很大,所以你有很多用户会话.拥有充满会话的大桌子本身不是问题.Yii DbSession 组件有一个垃圾收集器方法 gcSession() 在每次会话保存时调用Yii 会自动处理 session 表中的过期记录.

It seems, you have a big project, so you have many user sessions. Having big table full of sessions itself is not a problem. Yii DbSession component has a garbage collector method gcSession() that is called on each session save and Yii takes care about expired records in sessions table automatically.

所以是的,您需要所有这些.

So yes, you need all of them.

如果您的应用程序变慢,您可能需要调整您的 DBMS.有用的链接有一个很好的答案:MySQL 优化大表

If is slows your application, you might need to tune your DBMS. There is a good answer with useful links: MySQL optimization of huge table

这篇关于数据库中的 Yii2 会话存储,行太多?表现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆