title: Oracle insert architecture
body: <p>I have a question on the way that Oracle performs an <code>INSERT</code> action, and the reasons.</p>
  
  <p>I have read that when user execute some <code>INSERT</code> - Oracle process's need to retrieve the table data.</p>
  
  <p>I can understand that when user executes some select query, the instance's process need to retrieve this data from memory or from the disk (if it doesn't exists in memory).</p>
  
  <p>It also make sense with an <code>UPDATE</code> operation, since the old data need to be updated, so we must read that data.</p>
  
  <p>But when user execute an <code>INSERT</code> command - does it need to read any data from memory or disk files?</p>
  
  <p>Is that data need in goal to create the <code>"before image"</code> of the <code>redo log files</code>?</p>
  
  <p>Which data Oracle will retrieve for insert command?</p>
  
  <p>I'm using Oracle 11gR2.</p>
  
  <p>This is the text from the book:</p>
  
  <blockquote>
    <p>The following simple example of a row being inserted outlines how
    Oracle processes transactions:</p>
    
    <ol>
    <li>A user requests a connection to the Oracle server through a 3-tier or an n-tier web-based client using Oracle Net Services.</li>
    <li>Upon validating the request, the server starts a new dedicated server process for that user.</li>
    <li>The user executes a statement to insert a new row into a table.</li>
    <li>Oracle checks the user’s privileges to make sure the user has the necessary rights to perform the insertion. If the user’s privilege
    information isn’t already in the library cache, it will have to be
    read from disk into that cache.</li>
    <li>If the user has the requisite privileges, Oracle checks whether a previously executed SQL statement that’s similar to the one the user
    just issued is already in the shared pool. If there is, Oracle
    executes this version of the SQL; otherwise Oracle parses and executes
    the user’s SQL statement. Oracle then creates a private SQL area in
    the user session’s PGA.</li>
    <li>Oracle first checks whether the necessary data is already in the data buffer cache. If not, the server process reads the necessary
    table data from the datafiles on disk.</li>
    <li>Oracle immediately applies row-level locks, where needed, to prevent other processes from trying to change the same data
    simultaneously.</li>
    <li>The server writes the change vectors to the redo log buffer.</li>
    <li>The server modifies the table data (inserts the new row) in the data buffer cache.</li>
    <li>The user commits the transaction, making the insertion permanent. Oracle releases the row locks after the commit is issued.</li>
    <li>The log writer process immediately writes out the changed data in the redo log buffers to the online redo log file.</li>
    <li>The server process sends a message to the client process to indicate the successful completion of the INSERT operation. The
    message would be “COMMIT COMPLETE” in this case. (If it couldn’t
    complete the request successfully, it sends a message indicating the
    failure of the operation.)</li>
    <li>Changes made to the table by the insertion may not be written to disk right away. The database writer process writes the changes in
    batches, so it may be some time before the inserted information is
    actually written permanently to the database files on disk.</li>
    </ol>
  </blockquote>