<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Sequence Driven Primary Keys &#8211; Which is Better: Call NextVal in the Insert Statement or in a Row Level Trigger?</title>
	<atom:link href="http://hoopercharles.wordpress.com/2011/03/25/sequence-driven-primary-keys-which-is-better-call-nextval-in-the-insert-statement-or-in-a-row-level-trigger/feed/" rel="self" type="application/rss+xml" />
	<link>http://hoopercharles.wordpress.com/2011/03/25/sequence-driven-primary-keys-which-is-better-call-nextval-in-the-insert-statement-or-in-a-row-level-trigger/</link>
	<description>Miscellaneous Random Oracle Topics: Stop, Think, ... Understand</description>
	<lastBuildDate>Mon, 13 May 2013 14:10:06 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: damirvadas</title>
		<link>http://hoopercharles.wordpress.com/2011/03/25/sequence-driven-primary-keys-which-is-better-call-nextval-in-the-insert-statement-or-in-a-row-level-trigger/#comment-3664</link>
		<dc:creator><![CDATA[damirvadas]]></dc:creator>
		<pubDate>Thu, 14 Jul 2011 07:57:24 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4695#comment-3664</guid>
		<description><![CDATA[Charles,
Just to mention that comparing different versions of Oracle DB, should always be followed by different parameter settings according new features and specifics that this new version has.
If this is not true then any new Oracle DB version sis always slower on same hardware then previous one-tested that manually.
:-)]]></description>
		<content:encoded><![CDATA[<p>Charles,<br />
Just to mention that comparing different versions of Oracle DB, should always be followed by different parameter settings according new features and specifics that this new version has.<br />
If this is not true then any new Oracle DB version sis always slower on same hardware then previous one-tested that manually. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://hoopercharles.wordpress.com/2011/03/25/sequence-driven-primary-keys-which-is-better-call-nextval-in-the-insert-statement-or-in-a-row-level-trigger/#comment-3017</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Thu, 31 Mar 2011 12:01:10 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4695#comment-3017</guid>
		<description><![CDATA[Joaquin,

Sorry for the late reply.  

Thank you for providing the links.  I made it through the first half of the first link that your provided - those are long threads!  I may be remembering incorrectly, but isn&#039;t a SQL statement that is executed a single time in PL/SQL automatically added to the session&#039;s cached cursors, while the same SQL statement must be executed three times normally, before it is added to the session&#039;s cached cursors.  I believe that Tom Kyte called a session cached cursor hit a &quot;soft&quot; soft parse, which is almost as efficient as if the client had left the cursor open and re-executed the SQL statement - so the soft parse count might not be too much of an issue in this case.  Such a &quot;soft&quot; soft parse would still be included in the &quot;parse count (total)&quot; statistics, so I am not quite able to explain why that statistic value is roughly the same regardless of whether or not a row level trigger was used.

I think that I need to spend a little more time reading the threads that you linked to above.]]></description>
		<content:encoded><![CDATA[<p>Joaquin,</p>
<p>Sorry for the late reply.  </p>
<p>Thank you for providing the links.  I made it through the first half of the first link that your provided &#8211; those are long threads!  I may be remembering incorrectly, but isn&#8217;t a SQL statement that is executed a single time in PL/SQL automatically added to the session&#8217;s cached cursors, while the same SQL statement must be executed three times normally, before it is added to the session&#8217;s cached cursors.  I believe that Tom Kyte called a session cached cursor hit a &#8220;soft&#8221; soft parse, which is almost as efficient as if the client had left the cursor open and re-executed the SQL statement &#8211; so the soft parse count might not be too much of an issue in this case.  Such a &#8220;soft&#8221; soft parse would still be included in the &#8220;parse count (total)&#8221; statistics, so I am not quite able to explain why that statistic value is roughly the same regardless of whether or not a row level trigger was used.</p>
<p>I think that I need to spend a little more time reading the threads that you linked to above.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joaquin Gonzalez</title>
		<link>http://hoopercharles.wordpress.com/2011/03/25/sequence-driven-primary-keys-which-is-better-call-nextval-in-the-insert-statement-or-in-a-row-level-trigger/#comment-3015</link>
		<dc:creator><![CDATA[Joaquin Gonzalez]]></dc:creator>
		<pubDate>Tue, 29 Mar 2011 11:26:04 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4695#comment-3015</guid>
		<description><![CDATA[Charles,

Another thing to consider, is soft parsing of querys inside the trigger for multiple calls:
http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:2588723819082#56351588185822
Unless you are on 11g, where the changed the behavior:
http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:2588723819082#584022900346046668

Best regards

Joaquin Gonzalez]]></description>
		<content:encoded><![CDATA[<p>Charles,</p>
<p>Another thing to consider, is soft parsing of querys inside the trigger for multiple calls:<br />
<a href="http://asktom.oracle.com/pls/apex/f?p=100:11:0" rel="nofollow">http://asktom.oracle.com/pls/apex/f?p=100:11:0</a>::::P11_QUESTION_ID:2588723819082#56351588185822<br />
Unless you are on 11g, where the changed the behavior:<br />
<a href="http://asktom.oracle.com/pls/apex/f?p=100:11:0" rel="nofollow">http://asktom.oracle.com/pls/apex/f?p=100:11:0</a>::::P11_QUESTION_ID:2588723819082#584022900346046668</p>
<p>Best regards</p>
<p>Joaquin Gonzalez</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://hoopercharles.wordpress.com/2011/03/25/sequence-driven-primary-keys-which-is-better-call-nextval-in-the-insert-statement-or-in-a-row-level-trigger/#comment-3013</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Sat, 26 Mar 2011 15:17:58 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4695#comment-3013</guid>
		<description><![CDATA[Martin,

Thank you for the tip.  I wonder if the PL/SQL execution engine handles the two approaches identically behind the scenes?]]></description>
		<content:encoded><![CDATA[<p>Martin,</p>
<p>Thank you for the tip.  I wonder if the PL/SQL execution engine handles the two approaches identically behind the scenes?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://hoopercharles.wordpress.com/2011/03/25/sequence-driven-primary-keys-which-is-better-call-nextval-in-the-insert-statement-or-in-a-row-level-trigger/#comment-3012</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Sat, 26 Mar 2011 15:16:24 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4695#comment-3012</guid>
		<description><![CDATA[Mohamed,

That is an interesting point that you make about having to repeat the code to retrieve the next value from the sequence - that is something that I had not considered.  Having the sequence name located in one place would also make it a little easier to change the sequence name if that is necessary - but that is hopefully something that is very rare.  One of the bad points of relying on a triger, however, is that it makes it a little more difficult to understand how the primary key values are populated - something that might be critical when troubleshooting unexpected behavior.]]></description>
		<content:encoded><![CDATA[<p>Mohamed,</p>
<p>That is an interesting point that you make about having to repeat the code to retrieve the next value from the sequence &#8211; that is something that I had not considered.  Having the sequence name located in one place would also make it a little easier to change the sequence name if that is necessary &#8211; but that is hopefully something that is very rare.  One of the bad points of relying on a triger, however, is that it makes it a little more difficult to understand how the primary key values are populated &#8211; something that might be critical when troubleshooting unexpected behavior.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://hoopercharles.wordpress.com/2011/03/25/sequence-driven-primary-keys-which-is-better-call-nextval-in-the-insert-statement-or-in-a-row-level-trigger/#comment-3011</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Sat, 26 Mar 2011 15:07:33 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4695#comment-3011</guid>
		<description><![CDATA[I have updated the blog post with the second script.  

One part of the second script required nearly 4.5 hours to run on Oracle Database 11.1.0.6 on 64 bit Linux - that is much, much longer than the other release versions.  Almost all of that time was spent with the session running on the CPU - this appears to be related to context switching considering that the majorty of the other statistics were identical.  However, I cannot explain why 11.2.0.1 on 64 bit Linux did not suffer the same severe performance problem for that portion of the test script.

The amount of redo generated is interesting.  It appears that 11.1.0.6 and above have an optimization that reduces the amount of redo generated when a trigger is present to populate the primary key value using a trigger and a multi-row insert is performed.  On 10.2.0.2 and 10.2.0.5 the multi-row insert is essentially handled the same as many single row inserts when a trigger is present to populate the primary key column (more testing is probably required).  It appears that if the trigger is removed, the amount of redo generated drops on 10.2.0.2 and above when a multi-row insert is performed.  I believe that I have heard this feature described as batching block changes - notice that there is a sharp decrease in the number of &quot;db block gets&quot; when the redo generation drops significantly.]]></description>
		<content:encoded><![CDATA[<p>I have updated the blog post with the second script.  </p>
<p>One part of the second script required nearly 4.5 hours to run on Oracle Database 11.1.0.6 on 64 bit Linux &#8211; that is much, much longer than the other release versions.  Almost all of that time was spent with the session running on the CPU &#8211; this appears to be related to context switching considering that the majorty of the other statistics were identical.  However, I cannot explain why 11.2.0.1 on 64 bit Linux did not suffer the same severe performance problem for that portion of the test script.</p>
<p>The amount of redo generated is interesting.  It appears that 11.1.0.6 and above have an optimization that reduces the amount of redo generated when a trigger is present to populate the primary key value using a trigger and a multi-row insert is performed.  On 10.2.0.2 and 10.2.0.5 the multi-row insert is essentially handled the same as many single row inserts when a trigger is present to populate the primary key column (more testing is probably required).  It appears that if the trigger is removed, the amount of redo generated drops on 10.2.0.2 and above when a multi-row insert is performed.  I believe that I have heard this feature described as batching block changes &#8211; notice that there is a sharp decrease in the number of &#8220;db block gets&#8221; when the redo generation drops significantly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin</title>
		<link>http://hoopercharles.wordpress.com/2011/03/25/sequence-driven-primary-keys-which-is-better-call-nextval-in-the-insert-statement-or-in-a-row-level-trigger/#comment-3010</link>
		<dc:creator><![CDATA[Martin]]></dc:creator>
		<pubDate>Sat, 26 Mar 2011 12:07:25 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4695#comment-3010</guid>
		<description><![CDATA[I would have tried whether it makes a difference to code

OLD-WAY: 
    SELECT S1.NEXTVAL INTO :NEW.C1 FROM DUAL;
NEW-WAY: 
    :NEW.C1:=S1.NEXTVAL;

But there was not timing difference on my 11.2 db.]]></description>
		<content:encoded><![CDATA[<p>I would have tried whether it makes a difference to code</p>
<p>OLD-WAY:<br />
    SELECT S1.NEXTVAL INTO :NEW.C1 FROM DUAL;<br />
NEW-WAY:<br />
    :NEW.C1:=S1.NEXTVAL;</p>
<p>But there was not timing difference on my 11.2 db.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hourim</title>
		<link>http://hoopercharles.wordpress.com/2011/03/25/sequence-driven-primary-keys-which-is-better-call-nextval-in-the-insert-statement-or-in-a-row-level-trigger/#comment-3009</link>
		<dc:creator><![CDATA[hourim]]></dc:creator>
		<pubDate>Sat, 26 Mar 2011 07:57:05 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4695#comment-3009</guid>
		<description><![CDATA[Charles,

I have never thought about the performance gain one can get by using directly the sequence into the insert statement instead of using a row trigger for that. You are giving more strength to Tom Kyte when he says &quot;I hate triggers&quot;.

But I have only few remarks.

(a) Using the sequence directly into the insert statement needs to be done in every insert statement that needs to populate the corresponding primary key while the use of trigger  guarantees that every insert will be using the nextval on the trigger

(b) Recently we have backuped data of several parent/child tables from production to test environment. And it was very important to keep the same values of primary key/foreign key. We have disabled the constraints but forget to disable triggers that are responsible of populating PKs.This is why I prefer this:

CREATE OR REPLACE TRIGGER TR1
    BEFORE INSERT
    ON ST
    REFERENCING NEW AS NEW
    FOR EACH ROW
    BEGIN
    If :NEW.C1 IS NULL 
    THEN
      SELECT S1.NEXTVAL INTO :NEW.C1 FROM DUAL;
    END IF;
    END;
/   

Best regards

Mohamed Houri]]></description>
		<content:encoded><![CDATA[<p>Charles,</p>
<p>I have never thought about the performance gain one can get by using directly the sequence into the insert statement instead of using a row trigger for that. You are giving more strength to Tom Kyte when he says &#8220;I hate triggers&#8221;.</p>
<p>But I have only few remarks.</p>
<p>(a) Using the sequence directly into the insert statement needs to be done in every insert statement that needs to populate the corresponding primary key while the use of trigger  guarantees that every insert will be using the nextval on the trigger</p>
<p>(b) Recently we have backuped data of several parent/child tables from production to test environment. And it was very important to keep the same values of primary key/foreign key. We have disabled the constraints but forget to disable triggers that are responsible of populating PKs.This is why I prefer this:</p>
<p>CREATE OR REPLACE TRIGGER TR1<br />
    BEFORE INSERT<br />
    ON ST<br />
    REFERENCING NEW AS NEW<br />
    FOR EACH ROW<br />
    BEGIN<br />
    If :NEW.C1 IS NULL<br />
    THEN<br />
      SELECT S1.NEXTVAL INTO :NEW.C1 FROM DUAL;<br />
    END IF;<br />
    END;<br />
/   </p>
<p>Best regards</p>
<p>Mohamed Houri</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://hoopercharles.wordpress.com/2011/03/25/sequence-driven-primary-keys-which-is-better-call-nextval-in-the-insert-statement-or-in-a-row-level-trigger/#comment-3006</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Sat, 26 Mar 2011 02:10:28 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4695#comment-3006</guid>
		<description><![CDATA[Narendra,

Nice example of one potential difference... but there is a reason for the difference in redo generation and the number of DB BLOCK GETS.  I have a second test case script that demonstrates the reason for the redo difference.  It will likely take at least 10 to 12 hours before I update this article with the second test case script with output from Oracle Database 10.2.0.5, 11.1.0.7, and 11.2.0.1 all on 64 bit Windows; and 11.1.0.6 and 11.2.0.1 both on 64 bit Linux using similar hardware to what was used for the Windows test.  I do not have all of the results yet, but the results might be interesting.]]></description>
		<content:encoded><![CDATA[<p>Narendra,</p>
<p>Nice example of one potential difference&#8230; but there is a reason for the difference in redo generation and the number of DB BLOCK GETS.  I have a second test case script that demonstrates the reason for the redo difference.  It will likely take at least 10 to 12 hours before I update this article with the second test case script with output from Oracle Database 10.2.0.5, 11.1.0.7, and 11.2.0.1 all on 64 bit Windows; and 11.1.0.6 and 11.2.0.1 both on 64 bit Linux using similar hardware to what was used for the Windows test.  I do not have all of the results yet, but the results might be interesting.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Narendra</title>
		<link>http://hoopercharles.wordpress.com/2011/03/25/sequence-driven-primary-keys-which-is-better-call-nextval-in-the-insert-statement-or-in-a-row-level-trigger/#comment-2999</link>
		<dc:creator><![CDATA[Narendra]]></dc:creator>
		<pubDate>Fri, 25 Mar 2011 17:36:33 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4695#comment-2999</guid>
		<description><![CDATA[Let me give it a try
&lt;code&gt;
SQL&gt; select * from v$version ;

BANNER
----------------------------------------------------------------
Oracle Database 10g Release 10.2.0.1.0 - Production
PL/SQL Release 10.2.0.1.0 - Production
CORE	10.2.0.1.0	Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

SQL&gt; CREATE TABLE ST ( C1 NUMBER PRIMARY KEY, C2 VARCHAR2(20) );

Table created.

SQL&gt; CREATE SEQUENCE S1 START WITH 1 CACHE 1000;

Sequence created.

SQL&gt; CREATE OR REPLACE TRIGGER TR1
  2      BEFORE INSERT
  3      ON ST
  4      REFERENCING NEW AS NEW
  5      FOR EACH ROW
  6      BEGIN
  7      SELECT S1.NEXTVAL INTO :NEW.C1 FROM DUAL;
  8      END;
  9  /

Trigger created.

SQL&gt; CREATE TABLE NVT ( C1 NUMBER PRIMARY KEY, C2 VARCHAR2(20));

Table created.

SQL&gt; CREATE SEQUENCE S2 START WITH 1 CACHE 1000;

Sequence created.

SQL&gt; select sid from v$mystat where rownum = 1 ;

       SID
----------
       257

SQL&gt; set autotrace on statistics
SQL&gt; INSERT INTO ST(C2)
  2  SELECT
  3       RPAD(&#039;A&#039;,11,&#039;A&#039;)
  4    FROM
  5      DUAL
  6    CONNECT BY
  7      LEVEL &lt;= 100000;

100000 rows created.


Statistics
----------------------------------------------------------
     103113  recursive calls
     310732  db block gets
       1891  consistent gets
          1  physical reads
   52006188  redo size
        544  bytes sent via SQL*Net to client
        543  bytes received via SQL*Net from client
          3  SQL*Net roundtrips to/from client
          3  sorts (memory)
          0  sorts (disk)
     100000  rows processed

SQL&gt; 
SQL&gt; commit ;

Commit complete.

SQL&gt; INSERT INTO NVT(C1,C2)
  2  SELECT S2.NEXTVAL,
  3       RPAD(&#039;A&#039;,11,&#039;A&#039;)
  4    FROM
  5      DUAL
  6    CONNECT BY
  7      LEVEL &lt;= 100000;

100000 rows created.


Statistics
----------------------------------------------------------
       2995  recursive calls
       9277  db block gets
       1920  consistent gets
          0  physical reads
    8683212  redo size
        548  bytes sent via SQL*Net to client
        559  bytes received via SQL*Net from client
          3  SQL*Net roundtrips to/from client
          3  sorts (memory)
          0  sorts (disk)
     100000  rows processed

SQL&gt; commit ;

Commit complete.

SQL&gt; set autotrace off
SQL&gt; truncate table st reuse storage ;

Table truncated.

SQL&gt; truncate table nvt reuse storage ;

Table truncated.

SQL&gt; set autotrace on statistics
SQL&gt; INSERT INTO ST(C2)
  2  SELECT
  3       RPAD(&#039;A&#039;,11,&#039;A&#039;)
  4    FROM
  5      DUAL
  6    CONNECT BY
  7      LEVEL &lt;= 100000;

100000 rows created.


Statistics
----------------------------------------------------------
     101630  recursive calls
     309838  db block gets
       1179  consistent gets
         26  physical reads
   52014628  redo size
        550  bytes sent via SQL*Net to client
        543  bytes received via SQL*Net from client
          3  SQL*Net roundtrips to/from client
          2  sorts (memory)
          0  sorts (disk)
     100000  rows processed

SQL&gt; 
SQL&gt; commit ;

Commit complete.

SQL&gt; INSERT INTO NVT(C1,C2)
  2  SELECT S2.NEXTVAL,
  3       RPAD(&#039;A&#039;,11,&#039;A&#039;)
  4    FROM
  5      DUAL
  6    CONNECT BY
  7      LEVEL &lt;= 100000;

100000 rows created.


Statistics
----------------------------------------------------------
       1453  recursive calls
       8281  db block gets
       1353  consistent gets
         26  physical reads
    8625888  redo size
        552  bytes sent via SQL*Net to client
        559  bytes received via SQL*Net from client
          3  SQL*Net roundtrips to/from client
          2  sorts (memory)
          0  sorts (disk)
     100000  rows processed

SQL&gt; commit ;

Commit complete.

SQL&gt; spool off
&lt;/code&gt;

While the trigger approach generated about 49MB redo, the other approach generated just over 8MB of redo. I am not saying this is the main reason for the difference between run-time performance but my intention is to suggest that while the execution time is extremely important criteria, one should not ignore the impact on other factors.]]></description>
		<content:encoded><![CDATA[<p>Let me give it a try<br />
<code><br />
SQL&gt; select * from v$version ;</p>
<p>BANNER<br />
----------------------------------------------------------------<br />
Oracle Database 10g Release 10.2.0.1.0 - Production<br />
PL/SQL Release 10.2.0.1.0 - Production<br />
CORE	10.2.0.1.0	Production<br />
TNS for Linux: Version 10.2.0.1.0 - Production<br />
NLSRTL Version 10.2.0.1.0 - Production</p>
<p>SQL&gt; CREATE TABLE ST ( C1 NUMBER PRIMARY KEY, C2 VARCHAR2(20) );</p>
<p>Table created.</p>
<p>SQL&gt; CREATE SEQUENCE S1 START WITH 1 CACHE 1000;</p>
<p>Sequence created.</p>
<p>SQL&gt; CREATE OR REPLACE TRIGGER TR1<br />
  2      BEFORE INSERT<br />
  3      ON ST<br />
  4      REFERENCING NEW AS NEW<br />
  5      FOR EACH ROW<br />
  6      BEGIN<br />
  7      SELECT S1.NEXTVAL INTO :NEW.C1 FROM DUAL;<br />
  8      END;<br />
  9  /</p>
<p>Trigger created.</p>
<p>SQL&gt; CREATE TABLE NVT ( C1 NUMBER PRIMARY KEY, C2 VARCHAR2(20));</p>
<p>Table created.</p>
<p>SQL&gt; CREATE SEQUENCE S2 START WITH 1 CACHE 1000;</p>
<p>Sequence created.</p>
<p>SQL&gt; select sid from v$mystat where rownum = 1 ;</p>
<p>       SID<br />
----------<br />
       257</p>
<p>SQL&gt; set autotrace on statistics<br />
SQL&gt; INSERT INTO ST(C2)<br />
  2  SELECT<br />
  3       RPAD('A',11,'A')<br />
  4    FROM<br />
  5      DUAL<br />
  6    CONNECT BY<br />
  7      LEVEL &lt;= 100000;</p>
<p>100000 rows created.</p>
<p>Statistics<br />
----------------------------------------------------------<br />
     103113  recursive calls<br />
     310732  db block gets<br />
       1891  consistent gets<br />
          1  physical reads<br />
   52006188  redo size<br />
        544  bytes sent via SQL*Net to client<br />
        543  bytes received via SQL*Net from client<br />
          3  SQL*Net roundtrips to/from client<br />
          3  sorts (memory)<br />
          0  sorts (disk)<br />
     100000  rows processed</p>
<p>SQL&gt;<br />
SQL&gt; commit ;</p>
<p>Commit complete.</p>
<p>SQL&gt; INSERT INTO NVT(C1,C2)<br />
  2  SELECT S2.NEXTVAL,<br />
  3       RPAD('A',11,'A')<br />
  4    FROM<br />
  5      DUAL<br />
  6    CONNECT BY<br />
  7      LEVEL &lt;= 100000;</p>
<p>100000 rows created.</p>
<p>Statistics<br />
----------------------------------------------------------<br />
       2995  recursive calls<br />
       9277  db block gets<br />
       1920  consistent gets<br />
          0  physical reads<br />
    8683212  redo size<br />
        548  bytes sent via SQL*Net to client<br />
        559  bytes received via SQL*Net from client<br />
          3  SQL*Net roundtrips to/from client<br />
          3  sorts (memory)<br />
          0  sorts (disk)<br />
     100000  rows processed</p>
<p>SQL&gt; commit ;</p>
<p>Commit complete.</p>
<p>SQL&gt; set autotrace off<br />
SQL&gt; truncate table st reuse storage ;</p>
<p>Table truncated.</p>
<p>SQL&gt; truncate table nvt reuse storage ;</p>
<p>Table truncated.</p>
<p>SQL&gt; set autotrace on statistics<br />
SQL&gt; INSERT INTO ST(C2)<br />
  2  SELECT<br />
  3       RPAD('A',11,'A')<br />
  4    FROM<br />
  5      DUAL<br />
  6    CONNECT BY<br />
  7      LEVEL &lt;= 100000;</p>
<p>100000 rows created.</p>
<p>Statistics<br />
----------------------------------------------------------<br />
     101630  recursive calls<br />
     309838  db block gets<br />
       1179  consistent gets<br />
         26  physical reads<br />
   52014628  redo size<br />
        550  bytes sent via SQL*Net to client<br />
        543  bytes received via SQL*Net from client<br />
          3  SQL*Net roundtrips to/from client<br />
          2  sorts (memory)<br />
          0  sorts (disk)<br />
     100000  rows processed</p>
<p>SQL&gt;<br />
SQL&gt; commit ;</p>
<p>Commit complete.</p>
<p>SQL&gt; INSERT INTO NVT(C1,C2)<br />
  2  SELECT S2.NEXTVAL,<br />
  3       RPAD('A',11,'A')<br />
  4    FROM<br />
  5      DUAL<br />
  6    CONNECT BY<br />
  7      LEVEL &lt;= 100000;</p>
<p>100000 rows created.</p>
<p>Statistics<br />
----------------------------------------------------------<br />
       1453  recursive calls<br />
       8281  db block gets<br />
       1353  consistent gets<br />
         26  physical reads<br />
    8625888  redo size<br />
        552  bytes sent via SQL*Net to client<br />
        559  bytes received via SQL*Net from client<br />
          3  SQL*Net roundtrips to/from client<br />
          2  sorts (memory)<br />
          0  sorts (disk)<br />
     100000  rows processed</p>
<p>SQL&gt; commit ;</p>
<p>Commit complete.</p>
<p>SQL&gt; spool off<br />
</code></p>
<p>While the trigger approach generated about 49MB redo, the other approach generated just over 8MB of redo. I am not saying this is the main reason for the difference between run-time performance but my intention is to suggest that while the execution time is extremely important criteria, one should not ignore the impact on other factors.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
