Best way to Lock a Table in exclusive mode ?

Hi
I have a procedure that update a record in a table. This table is accessed for many work stations and these stations update this table several times. In average this table is updated 900,000 times a day. My oracle version is 9.02
In this table there are no deletes.
The records that are in this table are inserted by other process that is working ok.
My procedure do this:
Receive some parameters ( param1 , param2, param3)
IF condition = true THEN
LOCK TABLE my_table IN EXCLUSIVE MODE;
SELECT my_table_id INTO v_my_table_id FROM my_table WHERE available = 'Y' AND rownum = 1;
Update my_table set SET my_date = sysdate, my_field1 = param1, available = 'N' WHERE my_table_id = v_my_table_id;
COMMIT;
The problem here is that some times this process is very slow , and the lock in the table remains for a long time and suddenly the table is released.
I review the CPU of the server whereis the database; and is normal.
This process has been working for 2 years and now is failing.
Could you help me to know if there is a better way to do this process?
I can't undesrtand why this behaivor, if is a simple transaction.
I really appreciate your help
Lorein

A couple of cents from my side.
As Daniel and Justin indicated, you are abusing Oracle severely with your approach. You are forcing serialisation - only a single process can at a time get an available row from the table. If there are a 100 workstations looking for work, one one at a time can get a "work available" row from the table.
This has nothing to do with Oracle, or Oracle's locking, but everything to do with how your designed your code to get a "work available" row.
The basic problem is that
a) you do not care which specific row to lock, you only want any single random row with "work available"
b) Oracle's locking is designed to lock a row, or set of rows, as specified by explicit user instruction
This is contradictory. You do not explicitly state which single row to lock. You lock ALL row with "work available" - the where rownum=1 does NOT only lock the first row. That criteria is MEANINGLESS when Oracle SELECTs rows to process (and lock). That rownum criteria is only applied AFTERWARDS... which means after the locking has happened.
There are a couple of alternative and better performing approaches that you can use instead.
One that springs to mind is a form of optimistic locking - but instead of being optimistic about the locking part, you're optimistic about the selecting an unlocked row part.
Basic pseudo code:
1. select the rowid of a random row from "work available" rows (using DBMS_RANDOM, SAMPLE or similar techniques - and NOT rownum!)
2. attempt to lock that rowid using NO WAIT
3. if the lock fails, re-start at step 1
4. random row has been found and locked, proceed to process and update
5 commit
The optimistic part is steps 1 and 2 - the assumption is that doing a single row random select will most of the time select a row that is not locked, allowing multiple processes at the same time to select and lock and process different rows.

Similar Messages

  • Best way to update RBSELBEST table for invoice

    what is the best way to update RBSELBEST table for PO invoice? Is there any BAPI or FM for this?

    Thanks. I tried this one also, but it does not update the table.
    in case if someone used this, what parameters i need to pass for this to work?

  • What is the best way to lock down an iMac?

    What is the best way to lock down an iMac to a desk?

    Run a cable through the hole in the stand and lock it to the desk. There are lots of security products out there to do this, here is a good sample to look for:
    imac security lock cable

  • Best way to lock a file exclusively (?)

    Hi all,
    My problem is the following:
    I want to use file locking to prevent multiple instances of the same process to run simultaneously.
    I tried File's method createNewFile() in conjunction with file.delete(). But the JavaDoc of createNewFile() says we'd better use FileLock facility. What would be the way to do this? I do not understand how to get access to the FileChannel object which can tryLock() the file, as initially the file does not exist. Perhaps I'm missing something.
    Thanks,
    Cris

    Hi all,
    My problem is the following:
    I want to use file locking to prevent multiple
    instances of the same process to run simultaneously.This problem has been discussed previously and the best way to resolve it is not by using file locking but to bind to a high number port with a ServerSocket. You can only bind a port once per OS and this is behaviour that you can rely on across platforms.

  • Best way to update custom table

    Hello experts,
    Iu2019m writing a report program and after pulling data from a custom table Iu2019m modifying certain fields within internal table and then eventually update custom table. The way Iu2019m updating custom table is working fine. However Iu2019m concern about performance issues because Iu2019m doing update on custom table within loop.
    Here is my code for reference.
    *&      Form  update_contracts
          text
    -->  p1        text
    <--  p2        text
    FORM update_contracts .
    Update record in an internal table first
      loop at izsc_compliance into wa_zsc_compliance..
        wa_zsc_compliance-zapproval = c_accepted.
        wa_zsc_compliance-CHANGED_DT = sy-datum.
        wa_zsc_compliance-CHANGED_TM = sy-uzeit.
        wa_zsc_compliance-CHANGED_BY = sy-uname.
        modify izsc_compliance from wa_zsc_compliance index sy-tabix.
        write:/ sy-tabix, wa_zsc_compliance-vbeln_new, wa_zsc_compliance-zapproval.
        if p_test is initial.
          move wa_zsc_compliance to zsc_compliance.
          update zsc_compliance.
        endif..
      endloop.
    Write records to database
      if p_test = 'X'.
        skip.
        write:/ 'Test mode'.
      endif.
    ENDFORM.                    " update_contracts
    Iu2019m not certain if there is any better way by not doing update within loop and update custom table outside this loop.
    Many thanks in advance.

    Hi,
    Yes, there is a better way to update the custom table. That will be more performance oriented and will be a much cleaner approach. As, I am not much aware of the custom table structure which you have in your program, the best way that I can suggest is to remove the update statement from that check. I guess you are checking against the mode - test or production. Once you have done the check, put the selected entries in an internal table which is same as database table. And then in a single command - a single array operation as it is commonly called, you can update the custom table.
    Have a look at the following link
    [Overwriting Several Lines Using an Internal Table|http://help.sap.com/saphelp_bw33/helpdata/en/fc/eb3a94358411d1829f0000e829fbfe/content.htm]
    [Inserting or Changing Lines|http://help.sap.com/saphelp_bw33/helpdata/en/fc/eb3ac8358411d1829f0000e829fbfe/content.htm]
    You can also scan the forum for multiple links and references and sample examples.
    Hope this will help. The above approach will be much more performance oriented and will help to optimize. Also, check where exactly you are providing the locking feature if at applicable in your business functionality.
    Regards,
    Samantak.

  • Opinion needed on best way to map multiple table joins (of the same table)

    Hi all
    I have a query of the format:
    select A.col1, B.col1,C.col1
    FROM
    MASTER_TABLE A, ATTRIBUTE_TABLE B, ATTRIBUTE_TABLE C
    WHERE
    A.key1 = B.key1 (+)
    AND
    A.key1 = C.key1(+)
    AND
    B.key2(+) = 100001
    AND
    C.key2(+) = 100002
    As you can see, I am joining the master table to the attribute table MANY times over, (over 30 attributes in my actual query) and I am struggling to find the best way to map this efficiently as the comparison for script vs. mapping is 1:10 in execution time.
    I would appreciate the opinion of experienced OWB users as to how they would tackle this in a mapping and to see if they use the same approach as I have done.
    Many thanks
    Adi

    SELECT external_reference, b.attribute_value AS req_date,
    c.attribute_value AS network, d.attribute_value AS spid,
    e.attribute_value AS username, f.attribute_value AS ctype,
    g.attribute_value AS airtimecredit, h.attribute_value AS simnum,
    i.attribute_value AS lrcredit, j.attribute_value AS airlimitbar,
    k.attribute_value AS simtype, l.attribute_value AS vt,
    m.attribute_value AS gt, n.attribute_value AS dt,
    o.attribute_value AS datanum, p.attribute_value AS srtype,
    q.attribute_value AS faxnum,
    R.ATTRIBUTE_VALUE AS FAXSRTYPE,
    s.attribute_value AS extno,
    t.attribute_value AS tb, u.attribute_value AS gb
    v.attribute_value AS mb, w.attribute_value AS stolenbar,
    x.attribute_value AS hcredit, y.attribute_value AS adminbar,
    z.attribute_value AS portdate
    FROM csi_item_instances a,
    csi_iea_values b,
    csi_iea_values c,
    csi_iea_values d,
    csi_iea_values e,
    csi_iea_values f,
    csi_iea_values g,
    csi_iea_values h,
    csi_iea_values i,
    csi_iea_values j,
    csi_iea_values k,
    csi_iea_values l,
    csi_iea_values m,
    csi_iea_values n,
    csi_iea_values o,
    csi_iea_values p,
    csi_iea_values q,
    CSI_IEA_VALUES R,
    csi_iea_values s,
    csi_iea_values t,
    csi_iea_values u,
    csi_iea_values v,
    csi_iea_values w,
    csi_iea_values x,
    csi_iea_values y,
    csi_iea_values z
    WHERE a.instance_id = b.instance_id(+)
    AND a.instance_id = c.instance_id(+)
    AND a.instance_id = d.instance_id(+)
    AND a.instance_id = e.instance_id(+)
    AND a.instance_id = f.instance_id(+)
    AND A.INSTANCE_ID = G.INSTANCE_ID(+)
    AND a.instance_id = h.instance_id(+)
    AND a.instance_id = i.instance_id(+)
    AND a.instance_id = j.instance_id(+)
    AND a.instance_id = k.instance_id(+)
    AND a.instance_id = l.instance_id(+)
    AND a.instance_id = m.instance_id(+)
    AND a.instance_id = n.instance_id(+)
    AND a.instance_id = o.instance_id(+)
    AND a.instance_id = p.instance_id(+)
    AND a.instance_id = q.instance_id(+)
    AND A.INSTANCE_ID = R.INSTANCE_ID(+)
    AND a.instance_id = s.instance_id(+)
    AND a.instance_id = t.instance_id(+)
    AND a.instance_id = u.instance_id(+)
    AND a.instance_id = v.instance_id(+)
    AND a.instance_id = w.instance_id(+)
    AND a.instance_id = x.instance_id(+)
    AND a.instance_id = y.instance_id(+)
    AND a.instance_id = z.instance_id(+)
    AND b.attribute_id(+) = 10000
    AND c.attribute_id(+) = 10214
    AND d.attribute_id(+) = 10132
    AND e.attribute_id(+) = 10148
    AND f.attribute_id(+) = 10019
    AND g.attribute_id(+) = 10010
    AND h.attribute_id(+) = 10129
    AND i.attribute_id(+) = 10198
    AND j.attribute_id(+) = 10009
    AND k.attribute_id(+) = 10267
    AND l.attribute_id(+) = 10171
    AND m.attribute_id(+) = 10184
    AND n.attribute_id(+) = 10060
    AND o.attribute_id(+) = 10027
    AND p.attribute_id(+) = 10049
    AND q.attribute_id(+) = 10066
    AND R.ATTRIBUTE_ID(+) = 10068
    AND s.attribute_id(+) = 10065
    AND t.attribute_id(+) = 10141
    AND u.attribute_id(+) = 10072
    AND v.attribute_id(+) = 10207
    AND w.attribute_id(+) = 10135
    AND x.attribute_id(+) = 10107
    AND y.attribute_id(+) = 10008
    AND z.attribute_id(+) = 10103
    AND external_reference ='07920490103'
    If I run this it takes less than a second in TOAD, when mapped in OWB it takes ages. 10:1 is a conservative estimate. In reality it takes 15-20 minutes. CSI_IEA_VALUES has 30 million rows CSI_ITEM_INSTANCES has 500,000 rows.
    Hope that helps. I would love to know how others would tackle this query.

  • Business rules to  implement - BEST way -  triggers and mutating table

    I have the following table where it has Foreign Key defined on itself(self reference for parent_id column which can be null or valid site_id)
    create table test_virtual_site
    site_id number CONSTRAINT site_id_pk primary key,
    parent_id number CONSTRAINT parent_site_id_unq UNIQUE ,
    closed_date date default NULL ,
    CONSTRAINT check_self_ref CHECK(parent_site_id <> site_id), --avoid self refernce
    CONSTRAINT check_valid_site foreign key(parent_site_id) references test_virtual_site(site_id)
    I have the following business rules to implement and my problem is related to their implementation
    1)     A check should be made that Site_id specified as parent_id should not be a child of any other store (parent should have its parent_id column as NULL)
    Site_id Parent_id
    1
    2 1
    3 2 =>NOT VALID 2 is a child of another store
    2)     Parent is not closed
    Site_id Parent_id Closed_date
    1 10-May-2005
    3     1 =>NOT VALID 1 is a closed
    3)
    when parent store is closed - updated so at closed_date is not null
    Want to set the parent_id as NULL for the child store.
    OR
    SET the closed_date for child store too same as the parent_store.
    Example
    Site_id Parent_id Closed_date
    1     
    1 2
    Update test_virtual_site
    SET closed_date = sysdate
    Where site_id = 1 ;
    Through Trigger
    Site_id Parent_id Closed_date
    1     22-Mar-06
    1 2 22-Mar-06
    OR
    Site_id Parent_id Closed_date
    1     22-Mar-06
    1
    When I am trying to do the above mentioned through constraints I am running into mutating trigger problem. Can you please guide me what is the best way to handle the above-mentioned scenarios.
    I am aware that I can avoid the 3rd problem using the following
    -- - Initialize an array in the before statement trigger.
    -- - Add the processed rowid to the array in the after row
    -- trigger.
    -- - In the after statement trigger: get each rowid from the
    -- array and process it. When all rowids are processed, clear
    -- the array.
    BUT for 1 and 2 I need to look at the parent specified , the parent exists in the same table BUT I can not perform the lookup from the BEFORE INSERT ROW LEVEL trigger but I want to ensure at the row level , so if the parent store is closed or parent specifed itself is a child(not permissible) I want to rollback the insert – RAISE_APPLICATION_ERROR.
    Can you please guide me what is the best way to handle the above mentioned conditions .

    I have the following table where it has Foreign Key defined on itself(self reference for parent_id column which can be null or valid site_id)
    create table test_virtual_site
    site_id number CONSTRAINT site_id_pk primary key,
    parent_id number CONSTRAINT parent_site_id_unq UNIQUE ,
    closed_date date default NULL ,
    CONSTRAINT check_self_ref CHECK(parent_site_id <> site_id), --avoid self refernce
    CONSTRAINT check_valid_site foreign key(parent_site_id) references test_virtual_site(site_id)
    I have the following business rules to implement and my problem is related to their implementation
    1)     A check should be made that Site_id specified as parent_id should not be a child of any other store (parent should have its parent_id column as NULL)
    Site_id Parent_id
    1
    2 1
    3 2 =>NOT VALID 2 is a child of another store
    2)     Parent is not closed
    Site_id Parent_id Closed_date
    1 10-May-2005
    3     1 =>NOT VALID 1 is a closed
    3)
    when parent store is closed - updated so at closed_date is not null
    Want to set the parent_id as NULL for the child store.
    OR
    SET the closed_date for child store too same as the parent_store.
    Example
    Site_id Parent_id Closed_date
    1     
    1 2
    Update test_virtual_site
    SET closed_date = sysdate
    Where site_id = 1 ;
    Through Trigger
    Site_id Parent_id Closed_date
    1     22-Mar-06
    1 2 22-Mar-06
    OR
    Site_id Parent_id Closed_date
    1     22-Mar-06
    1
    When I am trying to do the above mentioned through constraints I am running into mutating trigger problem. Can you please guide me what is the best way to handle the above-mentioned scenarios.
    I am aware that I can avoid the 3rd problem using the following
    -- - Initialize an array in the before statement trigger.
    -- - Add the processed rowid to the array in the after row
    -- trigger.
    -- - In the after statement trigger: get each rowid from the
    -- array and process it. When all rowids are processed, clear
    -- the array.
    BUT for 1 and 2 I need to look at the parent specified , the parent exists in the same table BUT I can not perform the lookup from the BEFORE INSERT ROW LEVEL trigger but I want to ensure at the row level , so if the parent store is closed or parent specifed itself is a child(not permissible) I want to rollback the insert – RAISE_APPLICATION_ERROR.
    Can you please guide me what is the best way to handle the above mentioned conditions .

  • Best way to create a table based on another table

    Hello,
    I am trying to create a table based on another table with all the data in it. It has large data.
    create table <tablename> as select * from table1.
    Is this the best way of doing it or is there any other way. please advice.
    thanks

    I am suggested to create new table as
    create table <newtable> as
    select * from <oldtable> where rownum < 1;
    then
    alter table <newtable> compress;
    then
    insert /*+ append */ into <newtable> as select * from <oldtable>;
    but i getting an error saying missing values key words ora- 00926.
    please advice

  • Best way to clone a table?

    Hi,
    What is the best way to clone an existing table definition?
    What I mean is, I want to do the following:
    create table tab2 as
    select * from tab1;
    delete from tab2;
    commit;
    But clearly this involves copying all the data and then delete it. Is there a more efficient way?
    Another alternative I could think of is:
    create table tab2 as
    select * from tab1 where rownum < 2;
    delete from tab2;
    commit;
    This would copy only one row instead of all the rows in tab1. This is clearly much more efficient than the first approach, but I still don't like the idea of copying the data and deleting it.
    I am sure there would be a "cleaner" way. Any ideas?
    Thanks in advance,
    Rajesh

    Hi Justin,
    My work involves generating statistics by running various queries. So, I have written a few procedures that generate the statistics and insert into certain tables. Usually before starting to generate a new round of stats, I take back up of the previously generated data like this.
    Approach I:
    alter table summary_tab rename to summary_tab_20th;
    create table summary_tab as
    select * from summary_tab_20th
    where rownum < 2;
    delete from summary_tab;
    commit;
    Of course, another alternative I have is the following:
    Approach II:
    create table summary_tab_20th as
    select * from summary_tab;
    delete from summary_tab;
    commit;
    But I thought this is inefficient when compared to Approach I because it copies ALL the data from summary_tab to summary_tab_20th and then deletes ALL the data from summary_tab.
    However, one disadvantage with Approach I is that everytime I do this the stored procedure gets invalidated and I have to recompile it.
    So, that is where I stand. If all this looks very dirty, please suggest how I can 'clean up' my process :-)
    Thanks,
    Rajesh

  • Best way to check if table is empty or not

    Hi. I had to check if a table was empty or not, and found different solutions.
    One of them called my atention, I readed it was the best way to do it (some 'dual' trick from Steven Feuerstein, they say) :
    SELECT 1 FROM DUAL WHERE EXISTS (SELECT 'X' FROM TABLE);
    Plan
    SELECT STATEMENT ALL_ROWSCost: 4 Cardinality: 1           
         3 FILTER      
              1 FAST DUAL Cost: 2 Cardinality: 1
              2 INDEX FAST FULL SCAN INDEX (UNIQUE) TABLE.UB_PK Cost: 2 Cardinality: 1
    But doing some tests I found this query to have lower cost:
    SELECT 1 FROM TABLE WHERE ROWNUM=1;
    Plan
    SELECT STATEMENT ALL_ROWSCost: 2 Cardinality: 1           
         2 COUNT STOPKEY      
              1 INDEX FAST FULL SCAN INDEX (UNIQUE) TABLE.UB_PK Cost: 2 Cardinality: 1
    So, what about that dual table trick? Should I keep the 'select 1 where rownum=1' as best possible way?
    I know it shouldn't matter much, but just wanna know what method works best for checking empty tables :)
    Thanks.

    As already mentioned, you cannot just base it on cost, as the cost is not specifically a good indicator of the amount of work that will need to be done, it's just an internal figure calculated for that query and isn't really that comparible across different queries.
    If you're intending to see if there is data in a table because you want to know whether to query it or not, you are actually better to just try and query the data and capture the NO_DATA_FOUND exception and handle that.  In that case it requires no effort or cost up front.

  • Best way to to display tables with a select drop down

    I have created many SQL query report portlets, but I need a way for the users to select a specific acct nbr in a drop down list and then update a table on the same page. What is the best way to do this? I had created a Frame Driver, but I can not find a way to publish it to a page. Any ideas would be great, thanks.

    Hi,
    You can use a form based on table to do this. Build the form and publish it on the same page. The form can have a combination of various form items like textbox, textarea and drop down list etc. The form allows to query on the table and update the table.
    Thanks,
    Sharmila

  • Whats the best way to export a table.

    Hi guys
    i have a table with over 20 millions record in it. i want to export that table.
    my question is what is they best and fastest way to export this table and how much time it will take to export?
    Asif

    when i execute the export command i got the following error
    /u01/oracle/product/8.1.7/bin/exp dss/vox file=/usr/invoice_line_hist.dmp direct=Y feedback=25000 buffer=1000000 log=/usr/invoiceg
    Export: Release 8.1.7.4.0 - Production on Fri Dec 16 14:00:55 2005
    (c) Copyright 2000 Oracle Corporation. All rights reserved.
    Connected to: Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
    With the Partitioning option
    JServer Release 8.1.7.4.0 - Production
    EXP-00041: Export done in server's UTF8, different from user's
    character set US7ASCII
    EXP-00000: Export terminated unsuccessfully
    What should i do to get rid of this problem.

  • Best way to update a table with disinct values

    Hi, i would really appreciate some advise:
    I need to reguarly perform a task where i update 1 table with all the new data that has been entered from another table. I cant perform a complete insert as this will create duplicate data every time it runs so the only way i can think of is using cursors as per the script below:
    CREATE OR REPLACE PROCEDURE update_new_mem IS
    tmpVar NUMBER;
    CURSOR c_mem IS
    SELECT member_name,member_id
    FROM gym.members;
    crec c_mem%ROWTYPE;
    BEGIN
    OPEN c_mem;
    LOOP
    FETCH c_mem INTO crec;
    EXIT WHEN c_mem%NOTFOUND;
    BEGIN
    UPDATE gym.lifts
    SET name = crec.member_name
    WHERE member_id = crec.member_id;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN NULL;
    END;
    IF SQL%NOTFOUND THEN
    BEGIN
    INSERT INTO gym.lifts
    (name,member_id)
    VALUES (crec.member_name,crec.member_id);
    END;
    END IF;
    END LOOP;
    CLOSE c_mem;
    END update_new_mem;
    This method works but is there an easier (faster) way to update another table with new data only?
    Many thanks

    >
    This method works but is there an easier (faster) way to update another table with new data only?
    >
    Almost anything would be better than that slow-by-slow loop processing.
    You don't need a procedure you should just use MERGE for that. See the examples in the MERGE section of the SQL Language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9016.htm
    MERGE INTO bonuses D
       USING (SELECT employee_id, salary, department_id FROM employees
       WHERE department_id = 80) S
       ON (D.employee_id = S.employee_id)
       WHEN MATCHED THEN UPDATE SET D.bonus = D.bonus + S.salary*.01
         DELETE WHERE (S.salary > 8000)
       WHEN NOT MATCHED THEN INSERT (D.employee_id, D.bonus)
         VALUES (S.employee_id, S.salary*.01)
         WHERE (S.salary <= 8000);

  • Best way to create hierarchies tables

    Good morning all,
    I wanted to discuss the best practices of creating hierarchies to be consumed by OBIEE. As far as I understand, OBIEE has been optimized to use flattened hierarchies, such as:
    ROW_WID CITY COUNTRY
    1 NEW YORK CITY USA
    2 MOSCOW RUSSIA
    3 KIEV UKRAINE
    4 SYDNEY AUSTRALIA
    5 ATLANTA USA
    Let's call it option 1. The only problem with this is that it has a potential to grow very wide. Also, There's a chance for confusion when there're duplicate entries, such as "New York" (city) and "New York State". Also, it's not always possible to define hierarchical relationships between data in a flat table - so-called ragged hierarchies. I found two major way of dealing with those (stack and flattening them out). Are there any other ways to deal with those? Specifically, I'm interested in dealing with hierarchies that involve complex positioning (a person might be a manager vertically, but managed horizontally - or - a person can have 2 managers - on different levels).
    Also, in the example above - can I create dimensional outriggers (assign surrogate keys instead of text values to the dim - such as having NEW YORK as 100, MOSCOW as 200)? Sort of snowflaking a dimension. I was asked to do a proof of concept for this - but haven't been successful so far. If yes, could you please provide a simple Dim Outrigger < Dim < Fact diagram.
    Thank you

    Thanks Peter - I've checked that document before (I believe it's based on Kurt Wolffe's document on Siebel Analytics which I checked as well).
    This option is fine if you're not going to do frequent changes - but in my case - it'll be a hell to maintain. We're sort of trying to prototype best solution - and it seems as flattening hierarchies is the best option, of course, given its limitations.
    Also, there's another option of taking a different path and splitting and then building separate hierarchies

  • Best way to JOIN 3 tables into internal table ?

    Hi friends,
    i have the following issue:
    i need to join information of 3 different tables ( BUT000, BUT020 and ADRC ) concerning Business Partners and i need them into one internal table.
    how would this be achieved with best performance ?
    regards,
    CL

    Hi clemens,
    As per my understanding, u can further improve this  SQL By:
    1. first select only BU000 and BU020 with inner join and then select material details in different different itabs. and process This will surely reduce load on DB and may increase load  on ABAP which u can improve by using BINARY SERARCH!.
    (Important: if u are using two table in join and giviing only PARTNER which is primary key field in both tables in WHERE clasuse ... this should be the only criteria in where clasue then i Dont think it will affect performance .... how many record may be there, this query will be BEST performer... I hope it will fetch 750000 records whithin few seconds)
    2. Generally, U try to give more and more conditions in where clause on PRIMARY KEY fiedls only and not on not KEY fields...
    3. In worst case, fetch data from three differnt tables into three different itabs and then process, this is best and last way to reduce load on DB and will increase load on ABAP which can be manages as above..
    Still u want more info .. send codes to me.. We will try to make it more and more fast....
    Jogdand M B
    null
    Message was edited by:
            Jogdand M B

Maybe you are looking for