MySQL上的游标-好还是坏 [英] Cursors on MySQL - Good or Bad

查看:102
本文介绍了MySQL上的游标-好还是坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直听到人们对使用游标说不好,这在​​Microsoft SQL Server中尤其如此,因为它们非常慢. MySQL上的Cursors也是如此吗? MySQL中的游标也会降低性能吗?有人可以建议在MySQL中使用游标吗?

I have always heard people saying bad about using cursors and this is especially in Microsoft SQL Server as they are very slow. Is this the case with Cursors on MySQL as well? Does cursors in MySQL reduce performance as well? Can someone please advice on the usage of cursors in MySQL?

推荐答案

大多数现代数据库(包括MySQL)都旨在执行基于集合的操作.游标的问题在于它们执行基于行(或过程)的操作.因此,当您使用游标执行在现代DBMS上无需游标就可以完成的工作时,几乎总是会看到性能下降.

Most modern databases (including MySQL) are designed to perform set based operations. The problem with cursors is that they perform row based (or procedural) operations. Because of this you will almost always see a performance hits when you are using cursors to do a job that can be done without cursors on a modern DBMS.

请参阅这篇文章,该书的内容很不错他们俩.它是在考虑SQL Server的情况下编写的,但大多数概念都适用.

Take a look at this article, which does a decent job going over the two. It is written with SQL Server in mind but most of the concepts apply.

这篇关于MySQL上的游标-好还是坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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