title: How to improve performance of PHP OCI-Lob::save
body: <p>I have a script which imports a lot of text files, processes them and then saves the data to an Oracle database. It also saves a copy of the raw data file into a BLOB column. When importing 72 files, each with around 40,000 lines of data in them (~ 3.5Mb each), the script takes well over a minute to execute.</p>
  
  <p>After using xdebug to profile the script, it appears that calls to OCI-Lob::save are taking the most time (~90%). Here is the PHP code I'm using to save the BLOB - pretty standard I think:</p>
  
  <pre><code>$this-&gt;_db-&gt;setSQL('INSERT INTO IMPORTED_FILES (FILE_BLOB, FILE_NAME, LAST_MODIFIED_DATE, IMPORTED_BY, IMPORTED_DATE) VALUES
                          (EMPTY_BLOB(), :fileName, :lastMod, :userId, SYSDATE) RETURNING FILE_BLOB INTO :fileBlob');
      $blob = \oci_new_descriptor($this-&gt;_db-&gt;con);
      $this-&gt;_db-&gt;bind(":fileBlob",$blob,-1,OCI_B_BLOB);
      $this-&gt;_db-&gt;bind(':fileName',$this-&gt;_name);
      $this-&gt;_db-&gt;bind(':lastMod',$this-&gt;_lastModifiedDate);
      $this-&gt;_db-&gt;bind(':userId',$_SESSION['userid']);
      $this-&gt;_db-&gt;execute(false);
      $blob-&gt;save($this-&gt;_contents);
  </code></pre>
  
  <p>And the table definition:</p>
  
  <pre><code>CREATE TABLE IMPORTED_FILES
    (
      "FILE_ID" NUMBER(*,0) NOT NULL ENABLE,
      "FILE_BLOB" BLOB NOT NULL ENABLE,
      "FILE_NAME"          VARCHAR2(255 CHAR) NOT NULL ENABLE,
      "LAST_MODIFIED_DATE" VARCHAR2(255 CHAR) NOT NULL ENABLE,
      "IMPORTED_BY"        VARCHAR2(255 CHAR) NOT NULL ENABLE,
      "IMPORTED_DATE" DATE NOT NULL ENABLE,
      "REPORT" CLOB,
      CONSTRAINT "IMPORTED_FILES_PK" PRIMARY KEY ("FILE_ID") USING INDEX
      TABLESPACE "DATA_INDEX" ENABLE
    )
  </code></pre>
  
  <p>Is there any way to make saving BLOBs faster?</p>
  
  <h1>UPDATE</h1>
  
  <p>Not sure if this helps, but I found the following window in SQL Developer, which shows some parameters concerning the BLOB field. Can any of these settings be changed to make it more efficient?</p>
  
  <p><img src="https://i.stack.imgur.com/z1pHX.png" alt="enter image description here"></p>