游标verus while循环 - 游标的优点/缺点是什么? [英] Cursor verus while loop - what are the advantages/disadvantages of cursors?

查看:163
本文介绍了游标verus while循环 - 游标的优点/缺点是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用while循环而不是光标是个好主意吗?

解决方案

其中一些取决于DBMS,但通常:



优点:




  • 在逐行处理时优于循环



  • 缺点:




    • 不要扩展


    • 使用更多服务器资源


    • 增加tempdb上的负载


    • 不正确(例如,未打开相应的关闭)



    Is it a good idea to use while loop instead of a cursor? What are the advantages/disadvantages of cursors?

    解决方案

    Some of these depends on the DBMS, but generally:

    Pros:

    • Outperform loops when it comes to row-by-row processing

    • Works reasonably well with large datasets

    Cons:

    • Don't scale as well

    • Use more server resources

    • Increases load on tempdb

    • Can cause leaks if used incorrectly (eg. Open without corresponding Close)

    这篇关于游标verus while循环 - 游标的优点/缺点是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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