idataparameter oracle,Oracle绑定变量在C#.NET中的应用及意义(The application and significance of Oracle binding va...

Oracle绑定变量在C#.NET中的应用及意义(The application and significance of Oracle binding variables in c #.net)

Oracle绑定变量在C#.NET中的应用及意义(The application and significance of Oracle binding variables in c #.net)

One, what is a binding variable

Bind variable:

Select * from emp where empno = : empno;

Is a placeholder in the user in the query, it will tell Oracle "I will then provide a value for this variable, we need to generate a plan now, but when I actually execute the statement, will provide the real value of" should be used.

The essence is to replace the substitution variables for constants in SQL statements. The binding variable can make the SQL statements that are submitted every time exactly the same.

Why use binding variables

Using binding variables can reduce hard parsing and optimize the use of Shared pools. In oracle, there are two optional parsing processes for a committed SQL statement, one called hard parsing and one called soft parsing.

When a SQL statement submitted, oracle will first check the Shared buffer pool have exactly the same with the statement, if there is one soft analysis can do only, or hard analysis.

A hard parsing requires many steps such as analysis, parsing, security checks, execution paths, optimal access plans, and so on. It consumes a lot of CPU and resources.

For example, to query children numbered 001, the following two methods can be implemented:

Select * from t_child where childid = '001'; / / no binding variables are used

Select * from t_child where childid = : childid / / use binding variables

However, in practice, it is often a child who has the number of 001, and may never use it again; Then you can query child '002', then query '003' and so on. So every time the query is a new query, it needs to be hard parsed;

While the second query provides the bind variables: childid, provided its value at query execution time, query after once compiled, query plan is stored in the Shared pool, which can be used to retrieve and reuse; In terms of performance and scalability, the difference between the two is huge, even surprising;

If the binding va

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值