Advertisement

07.27.2005 at 04:27PM PDT, ID: 21506958
[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

Two For Loops: Performance Issue

Asked by jazzyline in Oracle Database

Tags: ,

Hello All,
I have two tables Table_A and Table_B. Table_A contains  unque id 's of 30,000 customers and Table_B contains the details of these customers which has 3 million records. I have to check for several types of order_num for each person. So I have taken two cursors cur_1 and Cur_2. Cur_1 contains unique id's of 30,000 from table_A. Cur_2 contains 3 million records of these customers from Table_B. I have to look for certain orders_nums for each person. So I loop through cur_1 and then loop through cur_2 to find details of each customer. But when I run the program, it takes ages and ultimately I'm logged out with the error message "Exceeded Session limit on CPU Usage". I spoke to my DBA but he says it's because of my "two FOR LOOPS" as it seems it has to loop through 3 million records 30 thousand times, if I'm not wrong. Can you suggest me a way arround it. My sample code looks like this:

cursor cur_1 is select cust_id from customers;
cursor cur_2 is select cust_id, order_num,  from diagnosis;
g number := 0;
g1 number := 0;
vcount1 number := 0;
vcount2 number:= 0;
vcount number := 0 ;
begin
for c1 in cur_1
loop
    for c2 in cur_2
    loop    
               if  c1.cust_id = c2.cust_id then
                   if c1.order_num in ('V200','V270','V600')  then
                   g := g+1;
                      if g>1 then
                      vcount1 :=1;
                      end if;
                  elsif c1.order_num between 'E550' and 'E770' then
                      g1 :=  g1+1;
                      if g1>1 then
                      vcount2 := 1;
                      end if;
                   end if;  
                   vcount := vcount1+vcount2;
                   if vcount >1 then
                   dbms_output.put_line( c1.cust_id ||'  '||vcount);    
                   end if;  
                end if;
     end loop;
   vcount1 := 0;
   vcount2 := 0;
   vcount := 0;
   g :=0;      
 end loop;  

Thanks in advance!Start Free Trial
[+][-]07.27.2005 at 05:35PM PDT, ID: 14542263

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

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

 
[+][-]07.28.2005 at 06:02AM PDT, ID: 14545161

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

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

 
[+][-]07.28.2005 at 06:05AM PDT, ID: 14545173

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.28.2005 at 08:06AM PDT, ID: 14546467

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 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.28.2005 at 05:07PM PDT, ID: 14551174

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.09.2005 at 02:24PM PDT, ID: 14637105

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 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.18.2006 at 10:27AM PST, ID: 15731591

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

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

 
[+][-]01.18.2006 at 10:47AM PST, ID: 15731756

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.18.2006 at 05:00PM PST, ID: 15735203

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 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.19.2006 at 08:26AM PST, ID: 15740005

View this solution now by starting your 30-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

Zone: Oracle Database
Tags: cursors, performance
Sign Up Now!
Solution Provided By: awking00
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20081112-EE-VQP-44