Cursors on MySQL - Good or Bad

前端 未结 3 1062
悲&欢浪女
悲&欢浪女 2021-02-06 12:27

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? D

3条回答
  •  清酒与你
    2021-02-06 12:38

    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.

    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.

提交回复
热议问题