"PL/SQL functions are slow," is common developer wisdom that derives from the tension between set-oriented SQL evaluation and statement-by-statement PL/SQL interpretation. We pursue the radical approach of compiling PL/SQL away, turning interpreted functions into regular subqueries that can then be efficiently evaluated together with their embracing SQL query, avoiding any PL/SQL to SQL context switches. Input PL/SQL functions may exhibit arbitrary control flow. Iteration, in particular, is compiled into SQL-level recursion. RDBMSs across the board reward this compilation effort with significant run time savings that render established developer lore questionable.
翻译:“PL/SQL 函数缓慢” 是来自设定方向的 SQL 评价和声明、PL/SQL 解释之间紧张关系的常见开发者智慧。 我们采取激进的做法,将PL/SQL 编辑为废版,将解释的功能转换为常规子查询,然后与接受SQL 查询一起进行高效评估,避免任何PL/SQL 到 SQL 上下文开关。输入PL/SQL 函数可能显示任意的控制流程。 输入PL/SQL 函数尤其被汇编为SQL 级的循环。