Bulk绑定是如何提高性能的。有空再翻译吧。(from oracle)
来源:互联网 发布:apache rewrite是什么 编辑:程序博客网 时间:2024/04/29 09:25
How Do Bulk Binds Improve Performance?
The assigning of values to PL/SQL variables in SQL statements is called binding. PL/SQL binding operations fall into three categories:
- in-bind When a PL/SQL variable or host variable is stored in the database by an
INSERT
orUPDATE
statement. - out-bind When a database value is assigned to a PL/SQL variable or a host variable by the
RETURNING
clause of anINSERT
,UPDATE
, orDELETE
statement. - define When a database value is assigned to a PL/SQL variable or a host variable by a
SELECT
orFETCH
statement.
A DML statement can transfer all the elements of a collection in a single operation, a process known as bulk binding. If the collection has 20 elements, bulk binding lets you perform the equivalent of 20 SELECT
, INSERT
, UPDATE
, or DELETE
statements using a single operation. This technique improves performance by minimizing the number of context switches between the PL/SQL and SQL engines. With bulk binds, entire collections, not just individual elements, are passed back and forth.
To do bulk binds with INSERT
, UPDATE
, and DELETE
statements, you enclose the SQL statement within a PL/SQL FORALL
statement.
To do bulk binds with SELECT
statements, you include the BULK
COLLECT
clause in the SELECT
statement instead of using INTO
.
For full details of the syntax and restrictions for these statements, see "FORALL Statement" and "SELECT INTO Statement".
Example: Performing a Bulk Bind with DELETE
The following DELETE
statement is sent to the SQL engine just once, even though it performs three DELETE
operations:
DECLARE TYPE NumList IS VARRAY(20) OF NUMBER; depts NumList := NumList(10, 30, 70); -- department numbersBEGIN FORALL i IN depts.FIRST..depts.LAST DELETE FROM emp WHERE deptno = depts(i);END;
Example: Performing a Bulk Bind with INSERT
In the example below, 5000 part numbers and names are loaded into index-by tables. All table elements are inserted into a database table twice: first using a FOR
loop, then using a FORALL
statement. The FORALL
version is much faster.
SQL> SET SERVEROUTPUT ONSQL> CREATE TABLE parts (pnum NUMBER(4), pname CHAR(15));Table created.SQL> GET test.sql 1 DECLARE 2 TYPE NumTab IS TABLE OF NUMBER(4) INDEX BY BINARY_INTEGER; 3 TYPE NameTab IS TABLE OF CHAR(15) INDEX BY BINARY_INTEGER; 4 pnums NumTab; 5 pnames NameTab; 6 t1 NUMBER(5); 7 t2 NUMBER(5); 8 t3 NUMBER(5); 9 10 11 BEGIN12 FOR j IN 1..5000 LOOP -- load index-by tables13 pnums(j) := j;14 pnames(j) := 'Part No. ' || TO_CHAR(j); 15 END LOOP;16 t1 := dbms_utility.get_time;17 FOR i IN 1..5000 LOOP -- use FOR loop18 INSERT INTO parts VALUES (pnums(i), pnames(i));19 END LOOP;20 t2 := dbms_utility.get_time;21 FORALL i IN 1..5000 -- use FORALL statement22 INSERT INTO parts VALUES (pnums(i), pnames(i));23 get_time(t3);24 dbms_output.put_line('Execution Time (secs)');25 dbms_output.put_line('---------------------');26 dbms_output.put_line('FOR loop: ' || TO_CHAR(t2 - t1));27 dbms_output.put_line('FORALL: ' || TO_CHAR(t3 - t2));28* END;SQL> /Execution Time (secs)---------------------FOR loop: 32FORALL: 3PL/SQL procedure successfully completed.
- Bulk绑定是如何提高性能的。有空再翻译吧。(from oracle)
- Bulk Binds对性能的提高
- oracle性能提高---批量绑定
- oracle性能提高---批量绑定
- PreparedStatement是如何大幅度提高性能的
- PreparedStatement是如何大幅度提高性能的
- PreparedStatement是如何大幅度提高性能的
- PreparedStatement是如何大幅度提高性能的
- PreparedStatement是如何大幅度提高性能的
- PreparedStatement是如何大幅度提高性能的
- sendfile是如何提高性能的
- 看看我的翻译是如何提高的。
- ORACLE Bulk Binding批量绑定
- Linux kernel 的 sendfile 是如何提高性能的
- Linux kernel 的 sendfile 是如何提高性能的
- Linux kernel 的 sendfile 是如何提高性能的
- Linux kernel 的 sendfile 是如何提高性能的
- oracle bulk collect 提高Oracle查询效率
- 为生活而挣扎
- 组播
- 我在外包公司做软件测试的日子20
- 英语之痛:好久也让老外在启蒙期就开始学习汉语
- stm 后缀名 asp ssi 调试 上传 木马
- Bulk绑定是如何提高性能的。有空再翻译吧。(from oracle)
- PHP程序与服务器端通讯的方法
- 找到了SOA比赛的最详细文档` 有初赛的具体交付文档等内容`已将DOC文件发到公用邮箱`
- myeclipse 4.11注册码
- 2006.6.2 16:00 ERP的一个软件下载地址,大家都下载看看`方便以后的讨论`http://www.rzsoft.net/jt/erpcc11.htm
- 使用COM客户端调用.NET对象
- SQL查询语句使用
- CVS over ssh配置
- Beijing 4 nights / 5 days