临时表可以代替游标吗 [英] Can a temporary table replace a cursor

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

问题描述

大家好!

我可以用临时表替换游标吗?
是提高性能的有效更改吗?

Hi everybody!

Can I replace a cursor with a temporary table?
Is it a valid change to increase performance?

Please help!

推荐答案

依赖-有关如何使用表的更多信息可以改善答案.

有关结果集大小的一些信息,我们是在谈论100行还是1000000行?

多少用户正在同时访问该表以进行查询?

如果只有一个会话生成查询/游标,并且没有其他用户访问查询所涉及的表,则可能是游标是最有效的方法,但这全取决于如何将其组合在一起.

问候
Espen Harlinn
Depends - a bit more information about how you are using the table(s) could improve the answers.

Some information about the size of the result set, are we talking about 100 rows or 1000000 rows?

How many users are concurrently accessing the table(s) for the query?

If there is only one session generating the query/cursor, and no other users accessing the tables involved with the query - it''s likely that the cursor is the most efficient approach - but it all depends on how this has been put together.

Regards
Espen Harlinn


虽然可以有效地将游标替换为临时表,但如果要从中获得任何性能提升,这实际上取决于您的具体问题.请阅读此artivlce,也可能是该artilce的上一篇与本网站链接的文章:
While it is valid to exchange a cursor for a temporary table it really depends on you concrete problem if you''ll get any performance gains out of it. Please read this artivlce and maybe also the previous one the author of that artilce linked to on this site: http://www.techrepublic.com/blog/datacenter/avoiding-cursors-with-sql-server-2005/412[^].

Hope that clears it up a little.

Cheers!


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

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