Oracle 中的 REF CURSOR 与 TABLE 函数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/750718/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 18:03:41  来源:igfitidea点击:

REF CURSOR versus TABLE function in Oracle

oracle

提问by Chakra

I have PL-SQL Packages which return REF Cursors when data has to be retrieved as part of the CRUD operations. Would it be faster if these cursors were replaced with TABLE functions ?

我有 PL-SQL 包,当必须作为 CRUD 操作的一部分检索数据时,它们会返回 REF 游标。如果将这些游标替换为 TABLE 函数会更快吗?

Thanks

谢谢

回答by drnk

IMO TABLE functions are more usefull if you planned to use pipelined table functions. It`s not be faster, because REF is only reference to memory. And all the work (parse, execute, fetch and etc.) will be processed out of the function that return REF Cursor. REF Cursors adds flexibility to the detriment of easy of support. That is another article from "MacLochlainns Weblog" about REF Cursors and pipelined functions - Reference Cursors - Why, when, and how?

如果您计划使用流水线表函数,IMO TABLE 函数会更有用。它不会更快,因为 REF 只是对内存的引用。并且所有的工作(解析、执行、获取等)都将在返回 REF Cursor 的函数之外处理。REF 游标增加了灵活性,但不利于支持。那是来自“MacLochlainns Weblog”的另一篇关于 REF 游标和流水线函数的文章 -参考游标 - 为什么、何时以及如何?