游标或通过临时表循环 [英] Cursors or Looping Through Temp Tables

查看:88
本文介绍了游标或通过临时表循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用游标或循环通过更好的选择临时表是一个更好的选择吗?

Is it better to use cursors or looping througb Temp tables is a better choice?

推荐答案

这一切都取决于你的情况,这两个选项都不是优选的性能。



当您需要在物理表的每一行上逐个执行多个操作时,更可取光标。因此,一次只有一行会在内存中。



但是,临时表在内存中有完整的表数据,你还需要维护额外的变量用于循环索引目的。



这只是一个小比较,你能详细描述你的情况吗?
It all depends on your situation, both options are not preferable in terms of performance.

Cursors are more preferable when you need to perform multiple operations one by one on each row of your physical table. So, only one row at a time would be in memory.

However, Temp Tables have your complete table data in memory, also you need to maintain additional variable for looping index purpose.

This is just a little comparison, Can you describe your situation in details ??


它们都存在,因为它们都很有用有时。这取决于实际情况。我会说创建一个可以加入的临时表通常更有效,但两者都是昂贵的选项
They both exist because both are useful at times. It depends on the situation. I would say that creating a temp table you can join against is often more efficient, but both are expensive options


这篇关于游标或通过临时表循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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