Mysql 在一条语句中多次删除或行。有限制吗?
我在 PHP/Mysql 中使用这样的语句:
DELETE FROM `site1` . `users` WHERE `email` IN ('[email protected]', '[email protected]', '[email protected]')
我一次可能有几百或几千个,这对 MySql 来说会是一个处理问题吗? “IN”函数使用的数组有限制吗?
谢谢
I'm using a statement like this with PHP/Mysql:
DELETE FROM `site1` . `users` WHERE `email` IN ('[email protected]', '[email protected]', '[email protected]')
I may have a few hundred or a thounsand at a time, will this be a problem for MySql to handle?
Is there a limit to the array used for the "IN" function?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据文档,没有具体的
IN 的参数数量限制:
“IN 列表中的值数量仅受 max_allowed_packet 值的限制。”
According to the documentation, there is no specific limit on the number of arguments to
IN
:"The number of values in the IN list is only limited by the max_allowed_packet value."
最佳实践我会将其批处理不超过 100 个,如果必须立即删除它们,您可以将它们包装在事务中。
Best practice I would batch it by no more than 100 and if they must be deleted at once you could wrap them in a transaction.
我将创建一个包含这些值的临时表,并从查询中引用该临时表。
I'd create a temporary table containing the values, and refer to that from the query.