Host Arrays – performance gain[通俗易懂]

Host Arrays – performance gain[通俗易懂]To achieve a better performance in Pro*C/C++ application, using host arrays would be efficient than

Host Arrays - performance gain

To achieve a better performance in Pro*C/C++ application, using host arrays would be efficient than the usage of the simple host variables during the data insert. This document is about to detail how much runtime savings we gain from using the host arrays when inserting data into an Oracle database table.

 

When using simple host variables to insert data, data inserting is one row based. For example, we have below SQL insert statement, and 4,500 rows to be inserted into the table EMP. During the execution, the SQL statement would be executing 4,500 times; one row at a time.

insert into table emp(empno, ename, sal) values(:hv1,:hv2,:hv3);

 

However, when an array of 4,500 members is declared and the data is stored in the host array, the database would consider a batch of data insert during the runtime, which is the 4,500 rows inserted would be treated as one transaction.

 

A Pro*C/C++ program is built to run the tests. Some elements of the program are as follows:

A C structure – Host array to hold all 4,500 data rows.

A timer – to calculate the time elapsed.

The program executes on a client workstation, which may test network round trips.

Enough table segments space provided, which does not need table to extent segments during the runtime.

Table EMP:

Name Null? Type

—————– ——– ————

EMPNO NOT NULL NUMBER(4)

ENAME VARCHAR2(20)

SAL NUMBER(7,2)

 

The program total run 7 times, each time, truncate table emp is used. below are the data collected.

 #1:

The total time of the LoopIns program execution = 1.609458

The total time of the ArrayHost program execution = 0.008854

Result: 99.450% saved.

 

#2:

The total time of the LoopIns program execution = 1.587075

The total time of the ArrayHost program execution = 0.008567

Result: 99.460% saved.

 

#3:

The total time of the LoopIns program execution = 1.531888

The total time of the ArrayHost program execution = 0.008677

Result: 99.434% saved.

 

#4:

The total time of the LoopIns program execution = 1.614283

The total time of the ArrayHost program execution = 0.008676

Result: 99.463% saved.

 

#5:

The total time of the LoopIns program execution = 1.564746

The total time of the ArrayHost program execution = 0.008582

Result: 99.452% saved.

 

#6:

The total time of the LoopIns program execution = 1.531173

The total time of the ArrayHost program execution = 0.008060

Result: 99.474 saved.

 

#7:

The total time of the LoopIns program execution = 1.461805

The total time of the ArrayHost program execution = 0.008107

Result: 99.445% saved.

 

On average, 99.454% runtime savings are achieved by using the host arrays to insert 4,500 rows of data into the database table. Therefore, based on above testing data, using host arrays do provide a better performance gain during the data processing.

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
转载请注明出处: https://daima100.com/6972.html

(0)
上一篇 2023-03-29
下一篇 2023-03-30

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注