我是否需要担心使用sequelize 的node.js 的mysql 连接池?
我是 Node.js 的新手,听说过连接池,这对我来说很有意义,因为连接是一项昂贵的操作。
我正在研究 mysql 使用哪个节点模块,我喜欢 Sequelize 的外观,因为它是一个 ORM。
我不确定是否需要担心 Sequelize 的连接池。我是否只需实例化它并为所有客户端重用它?
var sequelize = new Sequelize('database', 'username'[, 'password'])
另外,我是否需要担心正在执行的并行查询的数量?
例如,如果我循环遍历一个表并每行执行一个查询。如果有 1000 行或更多行会发生什么?
这些查询是否会立即执行?
如果是这样,您可以投入的金额是否有限制?
I'm new to node.js and have heard of connection pooling and it makes sense to me as the connection is an expensive operation.
I am looking at which node module to use for mysql and I like the look of Sequelize as it is an ORM.
I'm not sure if I need to worry about connection pooling with Sequelize. Do I just instantiate it and reuse it for all clients?
var sequelize = new Sequelize('database', 'username'[, 'password'])
Also, do I need to worry about the number of parallel queries being executed?
For example, if I am looping through a table and executing a query per row. What happens if there are 1000 or more rows?
Do those queries get executed all at once?
If so, is there a limit to the amount you can throw at it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
目前 Sequelize 没有使用池化。这在过去引起了很多问题,因此被删除。我将在后续版本的 Sequelize 中再次添加池化。目前,每个请求都会打开一个新连接。还有一个已知的错误,它会导致连接未关闭。由于下一版本的大幅增强,这一问题有望得到解决。我还将从当前使用的node-mysql更改为另一个mysql连接器,这要快得多。完成此操作后,我尝试再次添加池。
at the very moment Sequelize is not using pooling. This caused many problems in the past, so it was removed. I will add pooling again in later versions of Sequelize. At the moment, every request opens a new connection. There is also a known bug, which leads to unclosed connections. Due to heavy enhancements in the next version, this will hopefully be fixed. I will also change from the currently used node-mysql to another mysql connector, which is much faster. Once this is done, I try to add pooling again.