douying7289
2018-10-17 15:59
浏览 310
已采纳

需要澄清:Yii2,MySQL程序和临时表

In my PHP Yii2 project, I am calling a MySQL Stored Procedure that creates a temporary table among other things and takes about 3-4 seconds to complete.

Does Yii2 reuse the same database connection for all users or does it create a new one, every time a user visits the website? I understand that the temporary tables are relative to a connection.

So, if I have 50+ users at the same time using the feature that calls the procedure, then is there a chance that all the procedures try to use the same temp table?

图片转代码服务由CSDN问答提供 功能建议

在我的PHP Yii2项目中,我正在调用MySQL存储过程,该过程创建一个临时表以及其他内容 3-4秒即可完成。

Yii2是否为所有用户重复使用相同的数据库连接,或者每次用户访问网站时是否创建新的数据库连接? 我知道临时表是相对于连接的。

所以,如果我有50个以上的用户同时使用调用该过程的功能,那么是否有机会 程序尝试使用相同的临时表?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongzhoutuo0883 2018-10-17 16:36
    已采纳

    Temporary table is created for each connection. it means the table is created every time a user visits your site. But there isn't chance that calls of the procedure in different connections try to use the same temp table, because a temp table is visible only to current connection

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题