public function writeBlob($value)
  {
  	   $hash= md5($value);
  	   $handle= 0;
 
  	   //php_pdo_oci is too slow, It almost takes 5s. It is very fast after switching to php_oci driver.
  	   //IIS 7.5, FastCGI, PHP 5.3.10, ORACLE DATABASE 11g XE, blobs table have only 10,0000 records.
  	   $conn = Database::getConnectionInfo('default');
 	   $conn = oci_connect($conn['default']['username'],$conn['default']['password'],$conn['default']['database']);   
 	   $blob = oci_new_descriptor($conn, OCI_D_LOB);
 	   $stmt = oci_parse($conn,"begin identifier.write_blob(:hash,:blobid,:blob); end;");
 	   
 	   oci_bind_by_name($stmt, ":hash", $hash, 32, SQLT_CHR);
 	   oci_bind_by_name($stmt, ":blobid", $handle, 32, SQLT_INT);
 	   oci_bind_by_name($stmt, ":blob", $blob, -1, SQLT_BLOB);
 	   
 	   $bool = oci_execute($stmt, OCI_DEFAULT);
 	   if($handle) $blob->save($value);
 	   
 	   oci_free_statement($stmt);
 	   oci_commit($conn);
 	   oci_close($conn);
 	   
 	   /* 
 	   $stream= DatabaseConnection_oracle::stringToStream($value);
 	   
  	   $stmt= parent::prepare("begin identifier.write_blob(?,?,?); end;");
  	   $stmt->bindParam(1, $hash, PDO::PARAM_STR, 32);
       $stmt->bindParam(2, $handle, PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT, 32);
       $stmt->bindParam(3, $stream, PDO::PARAM_LOB);

       $stmt->execute();
       */
 	   
       $handle= ORACLE_BLOB_PREFIX.$handle;
       
       //syslog(LOG_ERR,"returning handle: ".$handle);
       
       return $handle;
  }

Comments

brianV’s picture

Title: writeBlob is too slow using php_pdo_oci » [Performance] use oci instead of pdo_oci for writeBlob
Version: 7.x-1.12 » 7.x-1.x-dev
Status: Active » Needs review
Issue tags: -slow
StatusFileSize
new1.88 KB

I've put the above change into a patch for review.

Note - I would like to see some definite bookmarks before we consider making this change as it seems... odd... to me.

soraver’s picture

Hi,
i get this error after patching

Notice: Trying to get property of non-object in DatabaseConnection_oracle->readBlob() (line 634 of C:\xampp\htdocs\aaaa\includes\database\oracle\database.inc).
Warning: oci_connect(): ORA-12154: TNS:could not resolve the connect identifier specified in DatabaseConnection_oracle->writeBlob() (line 594 of C:\xampp\htdocs\aaaa\includes\database\oracle\database.inc).
Warning: oci_new_descriptor() expects parameter 1 to be resource, boolean given in DatabaseConnection_oracle->writeBlob() (line 595 of C:\xampp\htdocs\aaaa\includes\database\oracle\database.inc).
Warning: oci_parse() expects parameter 1 to be resource, boolean given in DatabaseConnection_oracle->writeBlob() (line 596 of C:\xampp\htdocs\aaaa\includes\database\oracle\database.inc).
Warning: oci_bind_by_name() expects parameter 1 to be resource, null given in DatabaseConnection_oracle->writeBlob() (line 598 of C:\xampp\htdocs\aaaa\includes\database\oracle\database.inc).
Warning: oci_bind_by_name() expects parameter 1 to be resource, null given in DatabaseConnection_oracle->writeBlob() (line 599 of C:\xampp\htdocs\aaaa\includes\database\oracle\database.inc).
Warning: oci_bind_by_name() expects parameter 1 to be resource, null given in DatabaseConnection_oracle->writeBlob() (line 600 of C:\xampp\htdocs\aaaa\includes\database\oracle\database.inc).
Warning: oci_execute() expects parameter 1 to be resource, null given in DatabaseConnection_oracle->writeBlob() (line 602 of C:\xampp\htdocs\aaaa\includes\database\oracle\database.inc).
Warning: oci_free_statement() expects parameter 1 to be resource, null given in DatabaseConnection_oracle->writeBlob() (line 605 of C:\xampp\htdocs\aaaa\includes\database\oracle\database.inc).
Warning: oci_commit() expects parameter 1 to be resource, boolean given in DatabaseConnection_oracle->writeBlob() (line 606 of C:\xampp\htdocs\aaaa\includes\database\oracle\database.inc).
Warning: oci_close() expects parameter 1 to be resource, boolean given in DatabaseConnection_oracle->writeBlob() (line 607 of C:\xampp\htdocs\aaaa\includes\database\oracle\database.inc).
bohart’s picture

Status: Needs review » Closed (outdated)

D7 reached its EOL back in January 2025, and there is no active release for D7 for this module anymore.
Development or support is not planned for D7. All D7-related issues are marked as outdated in a bunch.

Everyone can apply the patches/suggestions above (not tested by the maintainers, tested by the community) to their D7 projects.
If the issue remains relevant for D10+ versions, merge requests with proposed solutions for a new module version (D10+) are welcome in a new follow-up issue.

Thanks!

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.