Oracle数据库访问 - 速度有问题? [英] Oracle DB access - having problems with speed?

查看:82
本文介绍了Oracle数据库访问 - 速度有问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为我做错了什么。我能够连接到甲骨文只需

罚款,执行查询等等,但我遇到了严重的问题

速度:(


例如,我机器上的以下PHP脚本执行大约6

秒:


<?

$ db_conn = ocilogon(" my_username"," my_password"," my_database");

$ loop_count = 1000;

$ query = 插入oratest(id,text)值(:id,:data)" ;;

$ parsed = ociparse($ db_conn,$ query);

ocibindbyname ($ parsed,":id",$ x,4);

ocibindbyname($ parsed,":data",$ now,14);

for ($ x = 1; $ x< = $ loop_count; $ x ++){

$ now = date(" YmdHis");

ociexecute($ parsed, OCI_DEFAULT);

ocicommit($ db_conn);

}

?>


但是,如果我有以下PL / SQL存储过程,它会在不到一秒的时间内执行




程序测试是

l_loop_count数字(10);

开始

l_loop_count:= 1000 ;

for x in 1..l_loop_count循环

执行立即''插入oratest(id,text)值(''|| x ||'',

''''''|| toolkit.get_timestamp ||'''''''';

提交;

结束循环;

结束;


请注意,这是我使用执行立即的唯一原因相反

只是使用普通的插入,是执行立即是一个小的

有点慢:)


基础表被定义为CREATE TABLE ORATEST(id

NUMBER(10)NOT NULL,text VARCHAR2(14)NOT NULL);,我正在使用PHP

4.3.1(是的,现在有点过时了)在Windows XP(SP2)上运行的Apache 1.3.22(我的Oracle附带的
),OCI8是

修订版1.183 ......如果其中任何一个有任何意义。


有没有人有过这个领域的经验?有什么东西我是b $ b俯瞰吗?任何提示都表示赞赏。我试图使用PHP做这件事的原因是我希望在我的软件的下一个版本的

下一个版本中具有对象功能仅使用

PL / SQL。


-

Markku Uttula

I think I''m doing something wrong. I''m able to connect to Oracle just
fine, execute queries and all, but I''m having serious problems with
the speed :(

For example, the following PHP-script on my machine executes about 6
seconds:

<?
$db_conn = ocilogon("my_username", "my_password", "my_database");
$loop_count = 1000;
$query = "insert into oratest (id, text) values (:id, :data)";
$parsed = ociparse($db_conn, $query);
ocibindbyname($parsed, ":id", $x, 4);
ocibindbyname($parsed, ":data", $now, 14);
for ($x = 1; $x <= $loop_count; $x++) {
$now = date("YmdHis");
ociexecute($parsed, OCI_DEFAULT);
ocicommit($db_conn);
}
?>

However, if I have the following PL/SQL -stored procedure, it executes
in less than a second:

procedure testing is
l_loop_count number(10);
begin
l_loop_count := 1000;
for x in 1..l_loop_count loop
execute immediate ''insert into oratest (id, text) values (''||x||'',
''''''||toolkit.get_timestamp||'''''')'';
commit;
end loop;
end;

Please note, that the only reason I used "execute immediate" instead
of just using a normal insert, was that execute immediate is a tiny
bit slower :)

The underlying table is defined as "CREATE TABLE ORATEST (id
NUMBER(10) NOT NULL, text VARCHAR2(14) NOT NULL);", I''m using PHP
4.3.1 (Yeah, somewhat outdated at the moment) on Apache 1.3.22 (the
one that came with my Oracle) running on Windows XP (SP2), OCI8 is
revision 1.183 ... in case any of this has any meaning.

Has anyone got experience on this field? Is there something I''m
overlooking? Any hints are appreciated. The reason I''m attempting to
do this with PHP is that I wish to have Object-capabilities in the
next version of my software, that has previously been built using just
PL/SQL.

--
Markku Uttula

推荐答案

db_conn = ocilogon(" my_username"," my_password"," my_database");
db_conn = ocilogon("my_username", "my_password", "my_database");


loop_count = 1000;
loop_count = 1000;


query ="插入oratest(id,text)值(:id,:data)" ;;
query = "insert into oratest (id, text) values (:id, :data)";


这篇关于Oracle数据库访问 - 速度有问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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