Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7028553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:24:12+00:00 2026-05-28T00:24:12+00:00

I have to process a large table (2.5B records) row by row in order

  • 0

I have to process a large table (2.5B records) row by row in order to keep track of two variables. As one can imagine, this is quite slow. I am looking for ideas on how to tune this procedure. Thank you.

declare
    cursor c_data is select /* +index(data data_pk) */ * from data order by data_id;
    r_data c_data%ROWTYPE;
    lst_b_prc number(15,8);
    lst_a_prc number(15,8);
begin
    open c_data;
    loop
        fetch c_data into r_data;
        exit when c_data%NOTFOUND;

        if r_data.BATS = 'B' then
            lst_b_prc := r_data.PRC;
        end if;
        if r_data.BATS = 'A' then
            lst_a_prc := r_data.PRC;
        end if;
        if r_data.BATS = 'T' then

          insert into trans .... lst_a_prc , lst_b_prc      
           end if;
    end loop;
    close c_data;
end;

The issue really comes down to finding efficient sql to track the latest PRC value when BATS=’A’ and BATS=’B’ for each BATS=’T’ record.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:24:13+00:00Added an answer on May 28, 2026 at 12:24 am

    If I understand your problem correctly, with a table of data like this:

    create table data as
    select 1 data_id, 'T' bats, 1 prc from dual union all
    select 2 data_id, 'A' bats, 2 prc from dual union all
    select 3 data_id, 'B' bats, 3 prc from dual union all
    select 4 data_id, 'T' bats, 4 prc from dual union all
    select 5 data_id, 'A' bats, 5 prc from dual union all
    select 6 data_id, 'T' bats, 6 prc from dual union all
    select 7 data_id, 'B' bats, 7 prc from dual union all
    select 8 data_id, 'T' bats, 8 prc from dual union all
    select 9 data_id, 'T' bats, 9 prc from dual;
    

    You you want to insert one row for each T, using the last PRC value for A and B. Which would look something like this:

    T data_id   Last A   Last B
    ---------   ------   ------
    1           null     null
    4           2        3
    6           5        3
    8           5        7
    9           5        7
    

    This query should work:

    select data_id, last_A, last_B
    from
    (
        select data_id, bats, prc
            ,max(case when bats = 'A' then prc else null end) over
                (order by data_id
                 rows between unbounded preceding and current row) last_A
            ,max(case when bats = 'B' then prc else null end) over
                (order by data_id
                 rows between unbounded preceding and current row) last_B
        from data
    )
    where bats = 'T';
    

    With so much data, you’ll probably want to use direct path writes and parallelism.
    The performance will largely depend on whether the sorting for the analytic functions can be done in memory or on disk. Optimizing memory can be very difficult, you’ll probably need to work with a DBA to allow your process to use as much memory as possible without causing problems for other processes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two very large enterprise tables in an Oracle 10g database. One table
I have two process and a shared memory zone, my workflow is like this.
I have a large table with millions of records. Table `price` ------------ id product
I am currently transferring a large amount of records from one table to another,
We are using Maven for a large build process (> 100 modules). We have
I have a daily batch process that involves selecting out a large number of
I have Process objects that are monitored from two different views. A Windows.Forms.ListView (actually
I have a process in Linux that's getting a segmentation fault. How can I
We have a process that needs to run every two hours. It's a process
I am trying to import data from a large database. I have two tables

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.