Optimizing Pl/SQL procedure for fast execution

Hi All,
What are the tips that we must take care while writing pl/sql procedure or function, that it execute smoothly without any strains or resources.
And if any of the procedure or function is not running fast enough is there any DBMS package or something like EXPLAIN PLAN to see the execution path used by optimizer or to analyze the code in that procedure or function to establish what causing the problem ?
Any help will be highly appriciated.
Thanking you and best regards.

And if any of the procedure or function is not running fast enough is there any DBMS package or something like EXPLAIN PLAN to see the execution path used by optimizer or to analyze the code in that procedure or function to establish what causing the problem ?
Yes it is. :)
Read this:
http://download-uk.oracle.com/docs/cd/B14117_01/server.101/b10752/toc.htm
Peter D.

Similar Messages

  • Need to wite pl sql procedure for dynamic select statement

    Need pl sql procedure for a Dynamic select statement which will drop tables older than 45 days
    select 'Drop table'||' ' ||STG_TBL_NAME||'_DTL_STG;' from IG_SESSION_LOG where substr(DTTM_STAMP, 1, 9) < current_date - 45 and INTF_STATUS=0 order by DTTM_STAMP desc;

    I used this to subtract any data older than 2 years, adjustments can be made so that it fits for forty five days, you can see how I changed it from the originaln dd-mon-yyyy to a "monyy", this way it doesn't become confused with the Static data in the in Oracle, and call back to the previous year when unnecessary:
    TO_NUMBER(TO_CHAR(A.MV_DATE,'YYMM')) >= TO_NUMBER(TO_CHAR(SYSDATE - 365, 'YYMM'))

  • Using cron-job to call the PL/SQL procedure for every 5 min

    Hi All,
    i wrote one procedure. using cron-job to call this PL/SQL procedure for every 5 min. i don't have any idea about cron job & what is thescript file formate .where can i place that script file. what are the details we placed in that script

    Really appreciate you. I like this approach .
    please give me advice for the below thing
    job_action =>an i give my procedure name under this?
    BEGIN
    -- Job defined entirely by the CREATE JOB procedure.
    DBMS_SCHEDULER.create_job (
    job_name => 'Job_schedule_update',
    job_type => 'PLSQL_BLOCK',
    job_action => 'BEGIN Schedule_update; END;',
    start_date => SYSTIMESTAMP,
    repeat_interval => 'FREQ=HOURLY;BYMINUTE=5',
    end_date => NULL,
    enabled => TRUE,
    comments => 'Job defined entirely by the CREATE JOB procedure.');
    END;

  • SQL Procedures for dimension maintenance?

    I can't seem to find any stored procedures for refreshing dimensions & measures in 10.2. Looking at version 10.1 of the OLAP reference lists procedures such as:
    execute dbms_awm.refresh_awdimension ('MYSCHEMA', 'MYAW', 'AW_PROD');Is there an equivalent in 10.2.0.3? The OLAP reference docs have changed quite significantly from 10.1 to 10.2, so I'd assume so too has the database and the methods it uses to refresh structure. Docs for 10.2 don't appear to mention refreshing structure anywhere.
    Can anyone point me in the right direction? We're essentially looking for the same functionality as is provided in AWM's Maintain Dimension/Measure wizards, only called from our own application.
    Thanks,
    Aaron

    Hi,
    Have you tried having AWM creating a maintenance script for you?
    In the end of the maintenance wizard theres an option for selecting "create to script" or something similar.
    This will generate an anonymous PL/SQL block you can put into whatever procedure or application you want as long as it can run PL/SQL.
    Ragnar

  • Pl/sql procedure for match-merge operator

    I have used the match-merge operator in OWB. I want to implement the same match-merge operation using a pl/sql procedure. Please help.

    Yes sure. Lets say, we have a table tab1, which has the following structure and data:
    First_name Last_name Address City
    JACK ANDREWS XYZ NY
    ANDREWS JACK NY
    Now, i want to write a procedure which matches and merges the above two records, into a single record.The matching is done with the help of the first_name and last_name columns.

  • PL/SQL procedure for deleting rows

    We have to delete rows from a table by initiating parallel processes depending on no of connections, and also variable commit frequency. The procedure has to start by itself in case of failure of 1 or more parallel processes, by identifying the position where it stopped. Please some one help me what would be th elogic needed to write the [rocedure.
    Thanks in Advance
    Edited by: 864979 on Jun 9, 2011 10:02 PM

    Be careful of how this is designed and coded. It is very easy to do it horribly wrong, causing contention and problems.
    Have a look at DBMS_PARALLE_EXECUTE.
    If the package is not available on your Oracle version, then look at {message:id=1534900} for a manual approach.

  • Use Secoandary Index for VBFA for fast execution .

    HI all,
               How can i use secoandary index for VBFA table to improve my select statement performance
    in ALV report.below statement executing very slow.
    SELECT
           vbelv
           POSNV
          vbtyp_v
          vbeln
          POSNN
          vbtyp_n
    FROM  VBFA
    INTO TABLE IT_TY_SD_FLOW_do
    FOR ALL ENTRIES IN IT_INV
    WHERE VBELN = IT_INV-VBELN
    AND   POSNV = IT_INV-POSNR
    AND   VBTYP_N = 'M'
    AND   VBTYP_V = 'J'.

    Your query will never be optimized if you do not check first whether your internal table used in the where clause has at least one row.
    If the table is empty you end up with a full table scan and this cannot be your objective.
    Have fun.

  • PL/SQL procedure for database activity monitoring

    Can anyone help me in writing a procedure which will help me in monitoring the database, i.e. if anybody changes something inside a table say add, update or delete then this procedure will tell me about every operation on that table??

    This has nothing to do with forms whatsoever, and also is already invented. Search the documentation for "audit" or take a look at this: http://www.oracle-base.com/articles/10g/auditing-10gr2.php
    cheers

  • Need PL/SQL procedure for file transfer local system to server location

    Hi Experts,
    The requirement is one file ex: text file,excel file is there in Local system suppose c:newfolder/test.txt.
    once run the concurrent program for this particular file in the local system should transfer into server location for the mentioned path.
    is it possible to do in PL/SQL or shell script.
    can you please share the code.
    Thanks
    Meher

    Meher Irk wrote:
    The requirement is one file ex: text file,excel file is there in Local system suppose c:newfolder/test.txt.
    once run the concurrent program for this particular file in the local system should transfer into server location for the mentioned path.Why do you want to copy a local file from the local client file system, via the Oracle database server, to a remote directory on the server?
    Why is the Oracle database server to be used? For what purpose?
    There are standard secure methods for a client to copy a file to a server. Such as sftp and scp. No complex Oracle database server layer needed in-between.
    So why do you want to use the Oracle database to act as the copy mechanism for you?
    It will only make sense if the local file is copied into the database (as a LOB or securefile) and managed by the database. I fail to see why Oracle should be acting as the go-between for the client file system copy process to the server file system. This introduces another moving part in the copy process. Adds more security issues. Adds more authentication issues. And what for?

  • Can any one please send me an update trigger (pl/sql procedure) for ap tables(ap_suppliers,ap_supplier_site_all,and contacts)

    Please send an query for update trigger for those tables .
         1: ap_suppliers
         2: ap_supplier_sites_all
         3: ap_supplier_contacts.
    Thanks,
    Chaitanya.

    Hi,
    Actually ID and Data are different names in my API. Here I mentioned like that.
    Am using Oracle 10g version.
    Yes I am going to get the multiple values using this Ref Cursor. The same ref cursor is used in another API of my package.
    In this API, the user actually enters Application_id and data. API should insert/update the version_master table with the inputs. See application_id is the foriegn key for app_master table.
    The requirement is whenever they enters application_id and data, if application_id already present in the version_master table, then the data should be updated and we should get a status flag for this using Out variable(i.e. using ref cursor only we are showing the status). if the application_id is not present in the version_master table, new record should be inserted. The sequence will generate the version_id for version_master table.
    But the Merge statement is working fine for update and insert also. Problem is am unable to see the success or failure through ref cursor. I don't know how exactly I can use this.
    If data is NULL the operation should be failed. i.e. I should get Failure status here. But am not getting this.
    Please remove the comments here and then check. If I use the NVL2 function I was able to get the status flag, i.e. S or F.
    OPEN resultset_o FOR
    SELECT NVL2 (data, 'S', 'F')
    FROM version_master
    WHERE application_id = application_id_i;
    1.How the value of data being not null will determine Success of the api and how null failure
    2.If the above select statement goes in to exception when others how I will no the failure
    I have to achieve the above scenarios.
    Please advice me.

  • Help with rewriting the query for faster execution.

    Hello Everybody,
    We are on Version
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
    I am trying to get data from tab1 where col8 is equal to ' ' at the same time If we 2 or 3 records matched on col1 and col2 with different dates(col3) i am only interested in getting one record with the least date....
    Here is the sample data...
    Col1 col2 col3 COL4 COl5 Col6 COL7 COL8 COL9
    12 1 17-JAN-13 1 5 7 9 1233333 25
    10 2 16-JAN-13 2 5 7 9 1233333 25
    10 2 14-JAN-13 2 5 7 9 1233333 25
    16 6 16-JAN-13 6 5 7 9 1233333 28
    16 6 09-OCT-12 5 5 7 9 1233333 29
    16 6 15-JAN-13 6 5 7 9 1233333 28
    17 5 09-OCT-12 5 5 7 9 1233333 29
    17 5 16-JAN-13 6 5 7 9 1233333 28
    17 5 10-OCT-12 5 5 7 9 1233333 29
    I am expecting output like this only should pull records...with min or least date
    Col1 col2 col3 COL4 COl5 Col6 COL7 COL8 COL9
    10 2 14-JAN-13 2 5 7 9 1233333 25
    16 6 09-OCT-12 5 5 7 9 1233333 29
    17 5 09-OCT-12 5 5 7 9 1233333 29
    Below query works and we have close to billion rows in a table but the where clause would filter out to 100 mill records.
    and i am trying to see if there is an effecient way of writing this....we have an index on COL3.
    Select col1,col2,col3,col4,col5,col6,col7,col8,col9 from(Selct of.,row_number() over (partition by col1,col2 order by col3 asc) as rnk
    from tabl of where of.col8 = '1233333') where rnk = 1*
    From the above query i get the below explain plan
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | Pstart| Pstop |
    | 0 | SELECT STATEMENT | | 1016M| 118G| | 13M (2)| 45:46:43 | | |
    |* 1 | VIEW | | 1016M| 118G| | 13M (2)| 45:46:43 | | |
    |* 2 | WINDOW SORT PUSHED RANK| | 1016M| 43G| 64G| 13M (2)| 45:46:43 | | |
    | 3 | PARTITION LIST SINGLE | | 1016M| 43G| | 1878K (3)| 06:15:47 | 4 | 4 |
    | 4 | TABLE ACCESS FULL | TAB1 | 1016M| 43G| | 1878K (3)| 06:15:47 | 4 | 4 |
    Predicate Information (identified by operation id):
    1 - filter("RNK"=1)
    2 - filter(ROW_NUMBER() OVER ( PARTITION BY "COL1","COl2" ORDER BY "COl3")<=1)
    17 rows selected
    Thanks In Advance!
    Edited by: 983949 on Jan 24, 2013 11:50 AM

    983949 wrote:
    Hello Everybody,
    I am trying to get data from tab1 where col8 is equal to ' ' at the same time.
    If we 2 or 3 records matched on col1 and col2 with different dates(col3)
    i am only interested in getting one record with the least date...
    Below query works and we have close to billion rows in a table but the where clause would filter out to 100 mill records.
    and i am trying to see if there is an effecient way of writing this....we have an index on COL3.
    Select col1,col2,col3,col4,col5,col6,col7,col8,col9
    from(Selct of.*,row_number() over (partition by col1,col2 order by col3 asc) as rnk
    from tabl of where of.col8 = '1233333') where rnk = 1
    Thanks In Advance!How do I ask a question on the forums?
    SQL and PL/SQL FAQ

  • Stored Procedures for Simple SQL statements

    Hi Guys,
    We are using Oracle 10g database and Web logic for frontend.
    The Product is previously developed in DotNet and SQL Server and now its going to develop into Java (Web Logic) and Oracle 10g database.
    Since the project is developed in SQL Server, there are lot many procedures written for simple sql queries. Now I would like to gather your suggestions / pointers on using procedures for simple select statements or Inserts from Java.
    I have gathered some list for using PL/SQL procedure for simple select queries like
    Cons
    If we use procedures for select statements there are lot many Ref Cursors opened for Simple select statements (Open cursors at huge rate)
    Simple select statements are much faster than executing them from Procedure
    Pros
    Code changes for modifying select query in PL/SQL much easier than in Java
    Your help in this regard is more valuable. Please post your points / thoughts here.
    Thanks & Regards
    Srinivas
    Edited by: Srinivas_Reddy on Dec 1, 2009 4:52 PM

    Srinivas_Reddy wrote:
    Cons
    If we use procedures for select statements there are lot many Ref Cursors opened for Simple select statements (Open cursors at huge rate)No entirely correct. All SQLs that hit the SQL engine are stored as cursors.
    On the client side, you have an interface that deals with this SQL cursor. It can be a Java class, a Delphi dataset, or a PL/SQL refcursor.
    Yes, cursors are created/opened at a huge rate by the SQL engine. But is is capable of doing that. What you need to do to facilitate that is send it SQLs that uses bind variables. This enables the SQL engine to simply re-use the existing cursor for that SQL.
    Simple select statements are much faster than executing them from ProcedureAlso not really correct. SQL performance is SQL performance. It has nothing to do with how you create the SQL on the client side and what client interface you use. The SQL engine does not care whether you use a PL/SQL ref cursor or a Java class as your client interface. That does not change the SQL engine's performance.
    Yes, this can change the performance on the client side. But that is entirely in the hands of the developer and how the developer selected to use the available client interfaces to interface with the SQL cursor in the SQL engine.
    Pros
    Code changes for modifying select query in PL/SQL much easier than in JavaThis is not a pro merely for ref cursors, but using PL/SQL as the abstraction layer for the data model implemented, and having it provide a "business function" interface to clients, instead of having the clients dealing with the complexities of the data model and SQL.
    I would seriously consider ref cursors in your environment. With PL/SQL servicing as the interface, there is a single place to tune SQL, and a single place to update SQL. It allows one to make data model changes without changing or even recompiling the client. It allows one to add new business logical and processing rules, again without having to touch the client.

  • Make EXE for Pl/sql procedure

    Hi all,
    I have one Pl/sql procedure for which i want make EXE.
    can we make EXE files for PL/sql procedures using ' Oracle Developer Tools for Visual Studio .NET'
    Thank you.

    Hi Al,
    Can you tell me in steps how to create EXE for pl/sql procedure using C# console application.
    I have one webservice link which i want to invoke and i have to put the webservice output in a saparate file.
    I wrote Pl/sql procedure which invokes/consumes the webservice using UTL_HTTP and also placed the output of Webservice in a saparate file using UTL_FILE.
    But i have to execute this procedure on a Workstation where there is No Oracle installed.
    as you suggested using C# console application. Will this Procedure with UTL_FILE & UTL_HTTP packages run in that c# console application.
    Thank you

  • Passing value from ADF to BPEL, and to PL/SQL  procedure

    1. I have created BPEL which take 2 inputs and concatenate them.
    2. have created a PL/SQL procedure for invoking this BPEL( working fine).
    Now i need to create a simple ADF page which contain 2 text box, 2 for input and 1 for result(concatenate), this will take 2 inputs and send them into BPEL, this will invoke the BPEL process and perform the necessary concatenate function...
    in addition to this, i am passing code into PL/SQL procedure ...
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body xmlns:ns1="http://xmlns.oracle.com/OrderImportDemo">
    <ns1:InputRequest>
    <ns1:FirstName>abcdef</ns1:FirstName>
    <ns1:LastName>aaaaaa</ns1:LastName>
    </ns1:InputRequest>
    </soap:Body>
    </soap:Envelope>';
    this code will take vaule from BPEL and run properly.
    can you please help me,

    thanks for help, but the problem is diff.
    i don't have any schema, what i want i need to create a adf page that will contain 3 tent field, 2 for input and 1 for output. when i will enter 2 input field and click on ok button, this will invoke BPEL, BPEL will take these 2 inputs and do the concat on this and send back to adf with result.

  • How to enable MSDOS program to be called from Oracle PL/SQL procedure ( Web Service )?

    Hello,
    Dealing with the time demanding procedure where power user is interactively execute sequence
    of steps of procedure:
    1. pl/sql procedure for preparing data in some table
    2. java program that read data from the table and creating input txt file for MSDOS program
    3. MSDOS program is autonomous component that reads input txt file and make
        output txtfile.
        MSDOS program is closed component, can not be modified
    4. java program that insert txtfile into Oracle table.
    5. Steps 1 to 4 are executed in interations driven with select on some table.
    Trying to prepare re-design the procedure  and not sure about which technologies to use ?
    The goal is that whole procedure would be implemented in pl/sql procedure and this way could be executed
    so as from power user from command line as from controlled application on any type of the client.
    So if that MSDOS program would be transformed as Web Service offered on  some MSWin server in the intranet.
    Then PL/SQL procedure would communicate ( call this web service ) and do all the job and at the end
    send status of completion and report through e-mail to the issuer of the procedure?
    Not sure what technologies should I use on Oracle RDBMS server on Linux to communicate with MSWin Web service which is running MSDOS program ?

    > Hi TOM,
    This is not asktom.oracle.com.
    > Can Possible to do in Oacle Pl/Sql...?
    Yes it can be done. Simply consult the applicable manuals that contains all of the details on how to do it. The manuals are:
    - Oracle® Database Application Developer's Guide - Large Objects (refer to Chapter 6 section on Using PL/SQL (DBMS_LOB Package) to Work with LOBs)
    - Oracle® Database PL/SQL Packages and Types Reference (refer to the chapter on DBMS_LOB)

Maybe you are looking for

  • Multiple Excise Invoice for Single GRPO

    Hello All How do we create multiple excise invoices from a single GRPO document. Thanks Santhosh.K

  • Is it possible to set default column widths in list view when using a finder window in Mavericks?

    The default 'document' column is way too wide and forces you eye to track all the way across the screen to read info like "date modified', 'kind' or 'size'. Tried several times to create a narrower default 'document name' column with no results. Coul

  • Sending Mail to a Comcast SMTP server

    Have a MAC PRO and MacBook Pro on the same network both running OS 10.8.2 with two identical email accounts having identical settings.  MAC PRO email accounts work as expected; able to send and receive emails.    However on the MacBook PRO, unable to

  • Upgrade to mac pro now FCP won't open files

    Howdy, i have upgraded from a 20" imac to an 8 core mac pro with 10 gigs ram-1.82 Terra HD and now I can't open the files I was working on with the imac. I can launch FCP but once I try to open a file it crashes the program. All software is up to dat

  • Connect to Azure Sql DB through WCF Data Service

    I am following the tutorial: http://msdn.microsoft.com/en-us/library/windowsazure/ee621789.aspx; Connect to Windows Azure SQL Database Through WCF Data service on a Windows 8 machine running VS2013.  Until starting this tutorial, I have only been usi