"LANGUAGE'plpgsql'VOLATILE"是什么意思? [英] what does “LANGUAGE 'plpgsql' VOLATILE” mean?

查看:1131
本文介绍了"LANGUAGE'plpgsql'VOLATILE"是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Postgres数据库中创建或更新函数或过程时,在函数末尾会看到LANGUAGE 'plpgsql' VOLATILE.
这是什么意思,目的是什么?

When I create or update a function or procedure in a Postgres database I see LANGUAGE 'plpgsql' VOLATILE at the end of function.
What does this mean and what is its purpose?

推荐答案

来自 Postgres文档:

VOLATILE表示该功能值甚至可以在 单表扫描,因此无法进行优化.相对较少 从这个意义上说,数据库功能是易变的.一些例子是 random(),currval(),timeofday().但请注意,任何具有 即使其后果相当严重,也必须将副作用归类为易失性 可预测的,以防止呼叫被优化掉;一个例子是 setval().

VOLATILE indicates that the function value can change even within a single table scan, so no optimizations can be made. Relatively few database functions are volatile in this sense; some examples are random(), currval(), timeofday(). But note that any function that has side-effects must be classified volatile, even if its result is quite predictable, to prevent calls from being optimized away; an example is setval().

这篇关于"LANGUAGE'plpgsql'VOLATILE"是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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