MySQL Cursors - Good or Bad

I have always heard people talk poorly about using cursors, and this is especially important in Microsoft SQL Server, because they are very slow. Does this also apply to cursors in MySQL? Do cursors in MySQL increase performance? Can anyone ask for advice on using cursors in MySQL?

+6
source share
3 answers

Most modern databases (including MySQL) are designed to perform set-based operations. The problem with cursors is that they perform string (or procedural) operations. Because of this, you will almost always see performance hit when you use cursors to complete a task that can be performed without cursors in a modern DBMS.

Take a look at this article , which does decent work on these two. It is written with SQL Server in mind, but most concepts apply.

+7
source

Just create and fill in the temporary table. Thus, most RDBMS implement cursors.

+1
source

Cursors are iterative in nature - they will definitely be slower regardless of the type of database. Therefore, you should do everything to avoid them and try to find solutions using SQL queries. However, they exist for problems that cannot be resolved with queries - so use them only when absolutely necessary.

-2
source

Source: https://habr.com/ru/post/894647/


All Articles