Advertisement

05.13.2007 at 11:09AM PDT, ID: 22569332
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.6

Insert question -Which is faster and why? Also, which is better?

Asked by Marilyn1374 in Oracle 10.x, PL / SQL

Tags: , ,

I am working on a project where the lead wants every 5000 records of an insert into a new table logged into a logging table.

I originally did not know this was needed functionality, so all I did in my proc to load the new table was
--METHOD 1
INSERT INTO new_table (column1, column2, column3)
(SELECT  col1, col2, col3
FROM old_table);

So now, I have this. This is just example code. Instead of outputting to screen in my real code, I am calling an inhouse logging procedure. I can't test it right now b/c my work oracle is down for some reason. I am guessing that the straight insert / select is faster than fetching the values into a cursor and then loading them into the new table.  

I need a good way to argue that Method1 is better. I can't think of a way to check the insert count while it is in proces that way the logging  per 5000 recs is captured as well.
 
/************* METHOD2 ************************/
DECLARE
   TYPE r_cursor IS REF CURSOR;

   c_example_tab      r_cursor;
   example_tab_rec     example_tab%ROWTYPE;
   v_count      INTEGER              := 0;
   v_string     VARCHAR2 (1500);

   TYPE example_tab_aarray IS TABLE OF new_table%ROWTYPE
      INDEX BY PLS_INTEGER;

   new_table_tab    example_tab_aarray;
BEGIN
   v_string :=
      ' BEGIN  INSERT INTO new_table(column1, column2, column3 )
 VALUES (:c1,:c2, :c3); END;';

   OPEN c_example_tab FOR
      SELECT col1, col2, col3
      FROM old_table;

   LOOP
      FETCH c_example_tab
      BULK COLLECT INTO new_table_tab;
      EXIT WHEN c_example_tab%NOTFOUND;
   END LOOP;

   FOR i IN 1 .. new_table_tab.COUNT
   LOOP
      EXECUTE IMMEDIATE v_string
                  USING new_table (i).column1,
                        new_table (i).column2,
                        new_table (i).column3;
           
      IF MOD (i, 5000) = 0
      THEN
         DBMS_OUTPUT.put_line ('Next 5000 inserted');
      END IF;
   END LOOP;

   COMMIT;
 
   CLOSE c_example_tab;
END;
Start Free Trial
[+][-]05.13.2007 at 12:33PM PDT, ID: 19081862

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Oracle 10.x, PL / SQL
Tags: insert, oracle, faster
Sign Up Now!
Solution Provided By: angelIII
Participating Experts: 3
Solution Grade: A
 
 
[+][-]05.13.2007 at 06:55PM PDT, ID: 19082626

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.13.2007 at 10:54PM PDT, ID: 19083115

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.13.2007 at 11:31PM PDT, ID: 19083231

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.13.2007 at 11:39PM PDT, ID: 19083258

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.13.2007 at 11:54PM PDT, ID: 19083296

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.14.2007 at 04:29AM PDT, ID: 19084153

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.14.2007 at 04:58AM PDT, ID: 19084273

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2007 at 05:04AM PDT, ID: 19084296

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2007 at 05:37AM PDT, ID: 19084489

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2007 at 08:09PM PDT, ID: 19090166

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32