在同一个连接上同时查询?

发布于 2024-12-05 05:47:41 字数 566 浏览 1 评论 0原文

我目前正在修改我的 C# 应用程序,并正在考虑对其 MySQL 部分进行以下操作:

  1. 服务器被调用来处理任何信息
  2. 服务器启动 MySQL 连接
  3. 服务器执行所需的所有查询和命令(可能发生同时查询?)
  4. MySQL 连接保持空闲第 3 号完成后 5 分钟
  5. 如果新请求在从第 4 号开始的 5 分钟内开始,则当最后一个请求结束时从 0 开始 5 分钟计数器
  6. MySQL 连接
  7. 从 2 开始

关闭我对此有一些疑问:

  • 单个连接是否允许我运行同时查询/命令(我知道很奇怪的问题,我还没有达到同时连接并且不确定如何测试它)?

  • 我最初考虑使用连接池,但由于我可能有一些查询需要一些时间才能完成,所以我选择不使用,这样我可以在连接打开时继续发送命令并得到他们的答复,这样可以吗?

  • 如果我不使用上述序列,而是简单地打开和关闭每个命令的连接,则应用程序可能会达到该 MySQL 用户的最大连接限制,正确吗?如果我没记错的话,连接数上限为 100 个。

I am currently modifying my C# application and was thinking of following this for the MySQL part of it:

  1. Server get called to process any information
  2. Server initiate MySQL connection
  3. Server do all queries and commands needed (possible to happen simultaneous queries ?)
  4. MySQL connection stays idle after number 3 finish for 5 minutes
  5. In case a new request begins within the 5 minutes from number 4, start the 5 minutes counter from 0 when the last request ends
  6. MySQL connection closes
  7. Starts from 2

I few doubts I was having in regards this were:

  • Will a single connection allow me to run simultaneous queries/commands (weird question I know, I haven't hit a simultaneous connection yet and am not sure how to test it) ?

  • I was initially thinking of using connection pooling but since I may have some queries that would take some time to finish, I opted for not, so I can keep sending commands and get their reply while the connection is open, is that OK ?

  • If instead of using the above sequence I simple open and close connections per command, it could happen that the application hits the max connection limit of that MySQL user is that correct ? if I am not mistaken there is a cap to 100 connections.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故事和酒 2024-12-12 05:47:41

单个连接是否允许我同时运行查询/命令

我最初考虑使用连接池,但由于我可能有一些查询需要一些时间才能完成,所以我选择不使用,这样我可以在连接打开时继续发送命令并得到他们的答复,这样可以吗?

是的,完全没问题,但如果您也在进行更新,请留意锁。

如果我不使用上述序列,而是简单地打开和关闭每个命令的连接,则应用程序可能会达到该 MySQL 用户的最大连接限制,正确吗?如果我没记错的话,连接数上限为 100 个。

实际上它是 151,但您可以根据需要更改此值。
请参阅: http://dev.mysql.com/doc /refman/5.5/en/too-many-connections.html

Will a single connection allow me to run simultaneous queries/commands

No.

I was initially thinking of using connection pooling but since I may have some queries that would take some time to finish, I opted for not, so I can keep sending commands and get their reply while the connection is open, is that OK ?

Yes, that's perfectly OK, keep an eye out for locks, if you are also doing updates though.

If instead of using the above sequence I simple open and close connections per command, it could happen that the application hits the max connection limit of that MySQL user is that correct ? if I am not mistaken there is a cap to 100 connections.

Actually its 151, but you can change this values if needed.
See: http://dev.mysql.com/doc/refman/5.5/en/too-many-connections.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文