Found out why it was so slow.

>  $e = OCIExecute($stmt);

The above commits every insert. It should be changed to

>  $e = OCIExecute($stmt,OCT_DEFAULT);

Then I got the expected results. Using bind vars is nearly twice as fast.


"John Lim" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hello,
> I recently benchmarked using bind variables for inserts versus sending
> simple sql over to oracle 8.1.7. Surprisingly, sending simple sql was
> nearly 6 times faster. My database is using cursor_sharing=force.
>
> Can anyone else verify this?
>
> >>>>>>> Not using bind variables (MySQL and Oracle), using ADOdb library:
>
> $DB->BeginTrans();
> for ($i=0; $i < $NUMRECS; $i++) {
>  $DB->Execute(
>         "insert into test5000 (name,price,stock) values ('a name
> $i',$i,$i)");
> }
> $DB->CommitTrans();
>
>
> >>>>>>>>>> Using bind variables:
>
> $DB->BeginTrans();
> $a = '';
> $b = 0;
> $c = 0;
> $stmt = OCIParse($DB->_connectionID,
>         "insert into test5000 (name,price,stock) values (:a,:b,:c)");
> OCIBindByName($stmt,":a",&$a,32);
> OCIBindByName($stmt,":b",&$b,32);
> OCIBindByName($stmt,":c",&$c,32);
> for ($i=0; $i < $NUMRECS; $i++) {
>  $a = "a name $i";
>  $b = $i;
>  $c = $i;
>  $e = OCIExecute($stmt);
>  if (!$e) {
>   print $DB->ErrorMsg();
>   break;
>  }
> }
> $DB->CommitTrans();
>
> ---
> For more details, see:
> http://php.weblogs.com/oracle_mysql_performance
>
>
>
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to