Speeding up query processing

Hi,
I was wondering if anyone had any suggestions on how to improve the performance of this code? All table used are indexed. The calling routine for this procedure is set into a for loop. I am working on Oracle8i release 8.1.7.4.0.
Thanks,
Darren
CREATE OR REPLACE PACKAGE aa_mars
AS
     PROCEDURE get_mars_info;
END aa_mars;
CREATE OR REPLACE PACKAGE BODY aa_mars
AS
PROCEDURE get_mars_info
IS
     Variables
     TYPE MPANS is TABLE OF by_recon_mpans.mpan_core%TYPE;
     mpan MPANS;     
     lv_module_name VARCHAR2(30) := 'Populate MARS Alignment Info';
     lv_sqlerrm VARCHAR2(2000) := '';
     ln_sqlcode NUMBER := 0;
     lv_error_text VARCHAR2(2000) := '';
     vv_control           VARCHAR2(20);          
BEGIN
     --dbms_output.put_line ('Started :'||TO_CHAR(SYSDATE,'DD/MM/YY HH24:MI:SS'));
     SELECT a.mpan_core BULK COLLECT
     INTO mpan
     FROM      by_recon_mpans a
     WHERE      NOT EXISTS(SELECT 1
                         FROM aa_mars_info b
                         WHERE a.mpan_core = b.mpan_core)
     AND      SUBSTR(a.mpan_core,1,2) IN (13,18)
     AND      ROWNUM < 2000;
/********** MARS DETAILS ******************************/
     FORALL i in mpan.FIRST..mpan.LAST
          INSERT      INTO aa_mars_info
                    mpan_core
          ,           reg_id
          ,           reg_efd
          ,           reg_etd
          ,           meter_id
          SELECT DISTINCT r.ms_mpan_core mpan_core
          ,           r.register_channel_id reg_id
          ,           MIN(r.effective_from_date) reg_efd
          , MAX( DECODE( r.effective_to_date, TO_DATE('01-JAN-4000', 'DD-MON-YYYY'),TO_DATE('31-DEC-2999', 'DD-MON-YYYY'),r.effective_to_date)) reg_etd
          ,           m.short_meter_id mtr_id
          FROM      registers@link_to_mars r
          ,           meters@link_to_mars m
          WHERE      m.meter_id=r.mtr_meter_id
          AND      m.effective_from=r.mtr_effective_from
          AND      r.ms_mpan_core = mpan(i)
          AND      r.effective_to_date IN (SELECT MAX (r1.effective_to_date)
                                             FROM registers@link_to_mars r1
                                                  WHERE r.ms_mpan_core = r1.ms_mpan_core)
          AND      r.mtr_meter_id IN (SELECT e.mtr_meter_id
                                        FROM registers@link_to_mars e
                                        WHERE e.ms_mpan_core=r.ms_mpan_core
                                        AND e.effective_to_date=r.effective_to_date)
          GROUP BY r.ms_mpan_core
          ,           r.register_channel_id          
          , m.short_meter_id;
          COMMIT;
     EXCEPTION HANDLER
     EXCEPTION
     WHEN OTHERS THEN
     lv_sqlerrm := SQLERRM;
     ln_sqlcode := SQLCODE;
     Tracker_Error_Handler.write_error(v_module_name => lv_module_name
                                             ,v_error_code => ln_sqlcode
                                             ,v_error_message => lv_sqlerrm
                                             ,v_additional_text => lv_error_text
                                             ,v_error_type => Dctrack_Constants.c_error_fatal);
     dbms_output.put_line(lv_error_text);
     ROLLBACK;     
END get_mars_info;
END aa_mars;
/

We only have read access on the database over the link. A view can be read only. I know, I know, what you mean is you aren't allowed to put additional objects on the remote database. Still I suggest you ask: it's it their interest to make your query as efficient as possible too, because they are the ones serving you the data, so it's dragging their system down too.
... without me having to copy all the tables to a local area?Well, that's what you're effectively doing anyway at the moment.
Do you have any further suggestions, Yes, use the LIMIT caluse in the bulk collect.
--  decalration section
CURSORC c_mpans IS
SELECT a.mpan_core
FROM by_recon_mpans a
WHERE NOT EXISTS(SELECT 1
FROM aa_mars_info b
WHERE a.mpan_core = b.mpan_core)
AND SUBSTR(a.mpan_core,1,2) IN (13,18);
BEGIN
   OPEN c_mpans;
   LOOP
       FETCH c_mpans BULK COLLECT INTO mpan LIMIT 2000;
       EXIT WHEN mpan.count() = 0;
       FORALL i IN mpan.FIRST..mpan.LAST
   END LOOP;
END;
/At least then you only call the procedure once and execute the main query once.
Cheers, APC

Similar Messages

  • Model Aggregate tables to speed up query processing

    Hi,
    Can anyone help me in the topics
    "Model Aggregate Tables to Speed up Query Processing"
    "Model Partitions and Fragments to improve application performance and usability"
    Am new to this concept, haven't worked on this before.
    Regards,
    Arun

    Arun wrote:
    Thanks. This would definitely help me out. But, i face issue in opening the repository in Online mode. Could you please tell me how to solve this issue?
    Here OBIEE server is lying on Unix Environment.
    I've created a repository in Windows Client.(Have installed OBIEE 11g developers client, BI Admin tool in my local machine).
    I would like to know the way to open a repository file in online mode in Client side.
    Regards,
    ArunCreate a 'BI Server' type ODBC connection in your windows environment pointing to your Unix box, then when you go open -> Online in admin tool you will see the entry as an option.
    Better to start a new thread when your original question is answered.

  • Downloading an app on to my iPad mini takes 15 minutes or more. Is there a way to speed up the process?

    Downloading an app on to my iPad mini takes 15 minutes or more just for one app is there a way to speed up the process?

    Maybe your internet is very slow.
    Try reset iPad
    Hold down the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears
    Note: Data will not be affected.

  • I have found that my Mac Book Pro 15 inch late 2011 is slower than my PC Windows 7 for certain downloads, and working with iPhoto.  Would adding RAM be helpful in speeding up this process.  Currently I have the stock 4GB RAM, and storage 500GB HD drive.

    I have found that my Mac Book Pro late 2011 15 inch is slower than I expected with certain downloads, or working with iPhoto than expected compared to my previous Windows 7 PC.  Would adding RAM be of any value in speeding up the process?

    how to tell if your mac needs more ram

  • Oracle 9i query processing

    Oracle 9.2.0.4.0
    Hi,
    Does oracle9i employ "Lazy Evaluation" in query processing?
    Thanks
    JN

    Lazy Evaluation applies in a number of cases, as does XPATH re-write. Both require structured (Schema based) XML documents. Can you provide more details about the queries you are interested in.

  • I just created a slideshow dvd in imovie, and when I hit finalize it said that it would take 7 hours to finalize.  I've only had my macbook pro for 6 months, and this is the first imovie I've done...is this normal?  If not how can I speed up this process?

    I just created a slideshow dvd in imovie, and when I hit finalize it said that it would take 7 hours to finalize.  I've only had my macbook pro for 6 months, and this is the first imovie I've done...is this normal?  If not how can I speed up this process?  Thanks in advance for all of your help!

    Hi
    Time needed can depend on several things.
    • less than 5 GB free space on Start-up (Mac OS) hard disk = Redicolous long times AND a DVD that most probably will not work OK
    Medicine - I never go under 25GB free space
    • Use of strange file formats into iDVD - can force it to de-code first then re-encode - this can take long long times
    I use
    Video - StreamingDV as from miniDV tape Cameras - or QuickTime Movies Converted to StreamingDV
    Audio - .aiff 16-bit 48 kHz - (no .mp3, .wma etc)
    • Use of old Mac - My G4 600MHz took about 24 hour per hour movie. my dG5 - about 2 hours per hour (I use Pro Quality encoding)
    • Pro Quality encoding - takes about x2 to process a movie
    Yours Bengt W

  • How to query Process Status from database in Project Server 2010

    Hello All,
    I am using Project Server 2010. 
    I need to query Process Status  from SQL. 
    where can I find Process Status in Database. 
    Thanks,
    Rohit

    Hi Rohit,
    you will not be able to find this information in reporting DB - the only database queries are supported.
    If you really want to go for an unsupported solution, you should be able to find related tables and how to join them in stored proc "MSP_WEB_SP_QRY_Statusing_ReadStatus" in published database.
    Regards
    Barbara
    To increase the value of this forum, please mark the replies that helped to solve your issue as answer. If you find answers to questions from other forum participants to be helpful, please mark them as helpful. Your participation will help others to find
    an appropriate solution faster. Thanks for your support!

  • Parallel Query processing in SQL server

    In stored procedure we are processing nearly 10 update statements with in a transaction, because  of synchronous query processing it is taking time to process all these queries ,I need to execute all the quires asynchronous processing can any
    one help me out how to process quires asynchronously?

    Hi,
    For most cases the need of using asynchronous
    statements processing
    is resolving using Service Broker
    SQL Server Service Broker provides native support for messaging and queuing applications in the SQL Server Database Engine. Service Broker, internal or external processes can send and receive guaranteed, asynchronous messaging by using extensions to
    Transact-SQL.
    SQL Server Service Broker
    http://msdn.microsoft.com/en-us/library/bb522893.aspx
    An Introduction to SQL Server Service Broker
    http://technet.microsoft.com/en-us/library/ms345108(v=sql.90).aspx
    [Personal Site] [Blog] [Facebook]

  • How to find query processing time?

    im using Oracle Express Edition
    i want to find the processing time of a query?,
    anyone please specify briefly how to find the query processing time
    can i get the processing time of a query by using Express edition or should i install Enterprise Edition.
    with regards,
    ravikanth.

    This link will help
    http://forums.oracle.com/forums/thread.jspa?threadID=2210335&tstart=0

  • How to speed up booting process

    I was lucky the way I could try out different ways of instaling Solaris 10 together with XP Pro. However same thing always happend. I do not know why but Solaris booting manager is slow in my opinion. I can't find out how to speed up this process. Can somebody give some advice???

    Hey, I am new to solaris, but I think maybe you should try installing solaris alone, with out XP Pro on the machine at all. I also see what you mean about the long system loading. Think of it this way, Unix and Windows are different, Unix has a more stability, and better config options than windows, so load time is a small price to pay. I would say My node take about 3 minutes to login from the time i turn the power on. Windows booted the same computer in 1 minute 40 seconds. BUT, the windows machine started to lagg after a week or so, I've been able to run my solaris for 3 weeks with out shutdown. now there is 1 more problem, how am i going to pay my electricity bill?

  • I have an iPod Touch 4g with 4.1 software, but it takes forever to update the software, how can I speed up the process?

    I have an iPod Touch 4g with 4.1 software, but it takes forever to update the software, how can I speed up the process?

    Nothing you can do. Presently the Apple servers are overloaded because of iOS 6.

  • Is there anyway of speeding up unlock process

    can you tell me if its possible to speed up unlocking process. i`ve contacted vodafone and they have sent request.

    No. It takes them as long as it takes them. They will send you an SMS when it's ready to plug into iTunes to complete the process.

  • How to Improve inserts into Template table for Query Processing

    Hi guys!
    I need your advice. How can i improve inserts into template table (/BI0/0P00000010 for exemple)? In my scenario i forced to load data from cube C_X to cubes C_1, C_2 and C_3.
    To get a goal i created a transformations and a DTP process with delta upload to each of cubes (C_1, C_2, C3). And that proccess takes about 3 hours! (it doesn't matter 1.000 or 100.000 records). But when i tried to load data with full update (with a filter) a proccess get data takes about 1 minutes.
    I traced process and saw that inserting into template table (which create each time when proccess started) take the longest time. How can i improve it?

    Hi Mahendar,
    It will require some efforts to investigate it so I propose to open a support ticket with Microsoft (through portal).
    Your first question interest me and I am not sure if you are doing proactive or reactive real time reporting. You can try with
    HBase for storing and retrieving data. HBase known for providing good read and write speed. If you are not comfortable writing HBase syntax then you can add an abstraction layer i.e. HIVE. It might take little more time when you
    query HBase from Hive.
    If you are doing real time analytic, then you can choose from Strom and Microsoft Azure Stream Analytic.
    Thanks and Regards,  
    Sudhir Rawat

  • Cell definition in BEx query processed in WEBI?

    Hello,
    We have defined cell definition in Business Explorer query. This query is processed by WEBI. My Querstion is: Does WEBI consider the cell definition from BEx Query?
    Thx for answer.

    Problem solved

  • Node variable in query - Processing type customer exit?

    We are on NW 2004S. I created a hierarchy for an info-object along with several nodes and child nodes.
    I also created a node variable in a query for this info-object. I have the following questions with regards to using node variables in a query.
    1) Can I use a node variable with processing type 'Customer Exit". My objective is to set the value of the node variable in the user exit.
    2) If answer to first question is "Yes", how would I code the node value in the user-exit - Example code or some pointers to that effect.
    I really appreciate your thoughts on this issue.
    Thanks,
    Sanjay

    Hi Sanjay,
    As far as I'm aware this hasn't changed in NW2004s, (in any case it still works), so:
    1)Yes you can, no difference with other type variables.
    2)In userexit EXIT_SAPLRRS0_001 (include ZXRSRU01).
    There's different options depending on at which stage you want to change it:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/f1/0a56f5e09411d2acb90000e829fbfe/frameset.htm
    If you do a forum search on above technical names I think you'll find plenty of coding samples, but if you want something more specific, I'd be happy to help you out.
    Regards,
    Pieter

Maybe you are looking for