How can I get an execution plan for a Function in oracle 10g

Hi
I have:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Solaris: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
I would like to know if is possible to get an EXECUTION PLAN for a FUNCTION if so, how can I get it ?
Regards

You can query the AWR data if your interesting SQL consumes enough resources.
Here is a SQL*Plus script I call MostCPUIntensiveSQLDuringInterval.sql (nice name eh?)
You'll need to know the AWR snap_id numbers for the time period of interest, then run it like this to show the top 20 SQLs during the interval:
@MostCPUIntensiveSQLDuringInterval 20The script outputs a statement to run when you are interested in looking at the plan for an interesting looking statement.
-- MostCPUintesticeSQLDuringInterval: Report on the top n SQL statements during an AWR snapshot interval.
-- The top statements are ranked by CPU usage
col inst_no             format      999 heading 'RAC|Node'
col sql_id              format a16      heading 'SQL_ID'
col plan_hash_value     format 999999999999 heading 'Plan|hash_value'
col parsing_schema_name format a12      heading 'Parsing|Schema'
col module              format a10      heading 'Module'
col pct_of_total   format        999.99 heading '% Total'
col cpu_time       format   999,999,999 heading 'CPU     |Time (ms)'
col elapsed_time   format   999,999,999 heading 'Elapsed |Time (ms)'
col lios           format 9,999,999,999 heading 'Logical|Reads'
col pios           format   999,999,999 heading 'Physical|Reads'
col execs          format    99,999,999 heading 'Executions'
col fetches        format    99,999,999 heading 'Fetches'
col sorts          format       999,999 heading 'Sorts'
col parse_calls    format       999,999 heading 'Parse|Calls'
col rows_processed format   999,999,999 heading 'Rows|Processed'
col iowaits        format   999,999,999,999 heading 'iowaits'
set lines 195
set pages 75
PROMPT Top &&1 SQL statements during interval
SELECT diff.*
FROM (SELECT e.instance_number inst_no
            ,e.sql_id
            ,e.plan_hash_value
            ,e.parsing_schema_name
            ,substr(trim(e.module),1,10) module
            ,ratio_to_report(e.cpu_time_total - b.cpu_time_total) over (partition by 1) * 100 pct_of_total
            ,(e.cpu_time_total - b.cpu_time_total)/1000 cpu_time
            ,(e.elapsed_time_total - b.elapsed_time_total)/1000 elapsed_time
            ,e.buffer_gets_total - b.buffer_gets_total lios
            ,e.disk_reads_total - b.disk_reads_total pios
            ,e.executions_total - b.executions_total execs
            ,e.fetches_total - b.fetches_total fetches
            ,e.sorts_total - b.sorts_total sorts
            ,e.parse_calls_total - b.parse_calls_total parse_calls
            ,e.rows_processed_total - b.rows_processed_total rows_processed
--            ,e.iowait_total - b.iowait_total iowaits
--            ,e.plsexec_time_total - b.plsexec_time_total plsql_time
      FROM dba_hist_sqlstat b  -- begining snap
          ,dba_hist_sqlstat e  -- ending snap
      WHERE b.sql_id = e.sql_id
      AND   b.dbid   = e.dbid
      AND   b.instance_number = e.instance_number
      and   b.plan_hash_value = e.plan_hash_value
      AND   b.snap_id = &LowSnapID
      AND   e.snap_id = &HighSnapID
      ORDER BY e.cpu_time_total - b.cpu_time_total DESC
     ) diff
WHERE ROWNUM <=&&1
set define off
prompt  to get the text of the SQL run the following:
prompt  @id2sql &SQL_id
prompt .
prompt  to obtain the execution plan for a session run the following:
prompt  select * from table(DBMS_XPLAN.DISPLAY_AWR('&SQL_ID'));
prompt  or
prompt  select * from table(DBMS_XPLAN.DISPLAY_AWR('&SQL_ID',NULL,NULL,'ALL'));
prompt .
set define on
undefine LowSnapID
undefine HighSnapIDI guess you'll need the companion script id2sql.sql, so here it is:
set lines 190
set verify off
declare
   maxDisplayLine  NUMBER := 150;  --max linesize to display the SQL
   WorkingLine     VARCHAR2(32000);
   CurrentLine     VARCHAR2(64);
   LineBreak       NUMBER;
   cursor ddl_cur is
      select sql_id
        ,sql_text
      from v$sqltext_with_newlines
      where sql_id='&1'
      order by piece
   ddlRec ddl_cur%ROWTYPE;
begin
   WorkingLine :='.';
   OPEN ddl_cur;
   LOOP
      FETCH ddl_cur INTO ddlRec;
      EXIT WHEN ddl_cur%NOTFOUND;
      IF ddl_cur%ROWCOUNT = 1 THEN
         dbms_output.put_line('.');
         dbms_output.put_line('   sql_id: '||ddlRec.sql_id);
         dbms_output.put_line('.');
         dbms_output.put_line('.');
         dbms_output.put_line('SQL Text');
         dbms_output.put_line('----------------------------------------------------------------');
      END IF;
      CurrentLine := ddlRec.sql_text;
      WHILE LENGTH(CurrentLine) > 1 LOOP
         IF INSTR(CurrentLine,CHR(10)) > 0 THEN -- if the current line has an embeded newline
            WorkingLine := WorkingLine||SUBSTR(CurrentLine,1,INSTR(CurrentLine,CHR(10))-1);  -- append up to new line
            CurrentLine := SUBSTR(CurrentLine,INSTR(CurrentLine,CHR(10))+1);  -- strip off up through new line character
            dbms_output.put_line(WorkingLine);  -- print the WorkingLine
            WorkingLine :='';                   -- reset the working line
         ELSE
            WorkingLine := WorkingLine||CurrentLine;  -- append the current line
            CurrentLine :='';  -- the rest of the line has been processed
            IF LENGTH(WorkingLine) > maxDisplayLine THEN   -- the line is morethan the display limit
               LineBreak := instr(substr(WorkingLine,1,maxDisplayLine),' ',-1); --find the last space before the display limit
               IF LineBreak = 0 THEN -- there is no space, so look for a comma instead
                  LineBreak := substr(WorkingLine,instr(substr(WorkingLine,1,maxDisplayLine),',',-1));
               END IF;
               IF LineBreak = 0 THEN -- no space or comma, so force the line break at maxDisplayLine
                 LineBreak := maxDisplayLine;
               END IF;
               dbms_output.put_line(substr(WorkingLine,1,LineBreak));
               WorkingLine:=substr(WorkingLine,LineBreak);
            END IF;
         END IF;
      END LOOP;
      --dbms_output.put(ddlRec.sql_text);
   END LOOP;
   dbms_output.put_line(WorkingLine);
   dbms_output.put_line('----------------------------------------------------------------');
   CLOSE ddl_cur;
END;
/

Similar Messages

  • How can I get the elapse time for execution of a Query for a session

    Hi ,
    How can I get the elapse time for execution of a Query for a session?
    Example - I have a report based on the procedure ,when the user execute that it takes say 3 min. to return rows.
    Is there any possible way to capture this session info. for this particular execution of query along with it's execution elapse time?
    Thanks in advance.

    Hi
    You can use the dbms_utility.get_time tool (gives binary_integer type value).
    1/ Initialize you time and date of beginning :
    v_beginTime := dbms_utility.get_time ;
    2/ Run you procedure...
    3/ Get end-time with :
    v_endTime := dbms_utility.get_time ;
    4/ Thus, calculate elapsed time by difference :
    v_elapsTime := v_endTime - v_beginTime ;
    This will give you time elapsed in of 100th of seconds...
    Then you can format you result to give correct print time.
    Hope it will help you.
    AL

  • How can I get a monthly subscription for combining PDF files

    How can I get a monthly subscription for combining PDF files. I have been able to subscribe in the past, but now all I see is annual subscription. I do not need an annual subscription because I do not use it often enough.

    Hi paige1186,
    The Adobe PDF Pack subscription, which allows you to combine PDF, is only available at an annual rate of $89.99. We do offer month-to-month subscriptions of Acrobat Pro and Standard, but I think you'd actually come out ahead with the annual PDF Pack subscription, if you planned on combining files more than 3-4 times throughout the year.
    Best,
    Sara

  • HT201318 How can I get a storage plan on iCloud that's more than 50GB?

    How can I get a storage plan on iCloud that's more than 50GB?

    Welcome to the Apple Community.
    If you purchase a higher-tier storage plan for your iCloud account to replace your existing storage plan (for example, a 20 GB plan to replace a 10 GB plan), the existing plan will be canceled and you will receive a prorated refund for the time remaining. The new storage plan is applied to your iCloud account and the annual payment date is updated to reflect the purchase date for the new plan.
    http://support.apple.com/kb/HT4874

  • I downloaded 11.1 but now can't access the store, can only view my library. I've reinstalled but still get a blank, white screen when I try to go to the itunes store. How can I get to the store for purchases?

    I downloaded 11.1 but now can't access the store, can only view my library. I've reinstalled but still get a blank, white screen when I try to go to the itunes store. How can I get to the store for purchases?

    In iTunes prefs>Store - is the Store check box unchecked?
    Did you repair pemissions with Disk Utility?
    MJ

  • Whenever I update my iPhone software, it asks me to sign in to iCloud with an old email address.  My other devices all have the correct address.  How can I get the correct address for my iPhone?  The only Apple ID that works for logging in is my new one.

    Whenever I update my iPhone software, it asks me to sign in to iCloud with an old email address.  My other devices all have the correct address.  How can I get the correct address for my iPhone?  The only Apple ID that works for logging in is my new one.

    To change the iCloud ID you have to go to Settings>iCloud, tap Delete Account, provide the password for the old ID when prompted to turn off Find My iPhone (if you're using iOS 7), then sign back in with the ID you wish to use.  If you don't know the password for your old ID, or if it isn't accepted, go to https//appleid.apple.com, click Manage my Apple ID and sign in with your current iCloud ID.  Tap edit next to the primary email account, tap Edit, change it back to your old email address and save the change.  Then edit the name of the account to change it back to your old email address.  You can now use your current password to turn off Find My iPhone on your device, even though it prompts you for the password for your old account ID. Then go to Settings>iCloud, tap Delete Account and choose Delete from My iDevice when prompted (your iCloud data will still be in iCloud).  Next, go back to https//appleid.apple.com and change your primary email address and iCloud ID name back to the way it was.  Now you can go to Settings>iCloud and sign in with your current iCloud ID and password.

  • How can i get a replacement remote for my apple tv

    how can i get a replacement remote for my apple tv?

    Welcome to the Apple Community.
    You can purchase them from the on-line or bricks and mortar Apple Store.

  • My ipod nano was synced by itunes and removed all of my music and game files. I am in the process of adding my music back one cd at a time, but there is no history of tetris that I paid for from the itunes store. How can I get this game back for my ipod?

    My ipod nano was synced by itunes and removed all of my music and game files, and replaced my music with my kids music that they have put into the current itunes library. My music is nowhere to be found on my computer, so now  I am in the long, forever process of adding my music back one cd at a time, but there is no history of tetris that I paid for from the itunes store. How can I get this game back for my ipod?

    Contact iTunes support and explain your situation to them.  They may let you redownload it at no cost.
    http://www.apple.com/support/itunes/contact.html
    If they don't, I'm afraid you'll have to purchase it again.  Sorry.
    B-rock

  • How can I get a better driver for my 1394b Hostcontroller in my Macbook pro 2010 to solve the problem, that it is too slow under Windows 7 installed with bootcamp ?

    How can I get a better driver for my 1394b Hostcontroller in my Macbook pro 2010 to solve the problem, that it is too slow under Windows 7 installed with bootcamp ?
    WIndows can't find a better one than the installed LSI Conformed 1394 Hostcontroller

    Read and follow the Bootcamp Installation instructions that you were offered to view when you ran Bootcamp Assistant.
    Run Bootcamp Assistant again and select the option to download the Bootcamp Support software. Follow the instructions. Then boot into Windows and install the Windows Support software you downloaded and saved.

  • I got the iphone 5, got some pics and msgs and contacts on it, and when i connected to my PC to restore my previous info from the old iphone, all the new stuff are gone, how can i get it back, thanks for help.

    i got the iphone 5, got some pics and msgs and contacts on it, and when i connected to my PC to restore my previous info from the old iphone, all the new stuff are gone, how can i get it back, thanks for help.

    The voicemail system used for the iPhone is different from the voicemail system used on the rest of the Verizon Wireless network. When you activate the iPhone, you lose your saved voicemails from the other system. When you activate a non-iphone, you lose any saved voicemails from the iPhone voicemail system too.

  • HT4528 I have the 4s and i downloaded ios 8 but nowmy battery will drop from 100 to 0 in 30 mins without me using it. it has also happened to my sisters phone and our upgrade isnt until december. how can i get rid of ios8 for anyting else?

    I have the 4s and i downloaded ios 8 but nowmy battery will drop from 100 to 0 in 30 mins without me using it. it has also happened to my sisters phone and our upgrade isnt until december. how can i get rid of ios8 for anyting else?

    Downgrading the iOS is not supported.  Basic troubleshooting steps are restart, reset, restore from backup, restore as new device

  • I downloaded a Trial version of Adobe Acrobat XI.  Now the trial has runout and I've signed up for a subscription.  However, my software still needs a serial number.  How can I get a serial number for the installed software?

    I downloaded a Trial version of Adobe Acrobat XI.  Now the trial has runout and I've signed up for a subscription.  However, my software still needs a serial number.  How can I get a serial number for the installed software?

    There is no serial number and you don't need one. What you need for a subscription is to SIGN IN within Acrobat, so it knows the subscriptions you own.

  • How do I get a data plan for iPad

    How do I get a data plan for my ipad

    Check with your wireless carrier to see if they offer a MiFi device.
    http://en.wikipedia.org/wiki/MiFi

  • How can I get a user manual for my inherited Blackberry ...

    How can I get a user manual for my inherited Blackberry Curve 8330?

    Hi and Welcome to the Forums!
    Here is a link to the manuals:
    http://na.blackberry.com/eng/support/docs/subcategories/?userType=1&category=BlackBerry+Smartphones&...
    Cheers!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • How can I get a serial number for Illustrator CS5?

    How can I get a serial number for Illustrator CS5 when I have a complete CC subscription?
    I have a GCC Expert 24 plotter running on OS X and the direct cut plugin is only compatible with CS5 or earlier.
    I have tried asking in support chat but it never actually works, my next option is to ring or get a cracked version but i'm trying to avoid both of those options if I can.
    Thanks.

    xdmg,
    In addition to what Lutz said, unless you buy a CS5 that is still new and unused, you will need a licence transfer through Adobe,
    http://helpx.adobe.com/x-productkb/policy-pricing/transfer-product-license.html
    and the application must be deactivated on any machine it has been installed on.

Maybe you are looking for

  • A lot of questions

    Background. A while ago I asked for some advice about external drives. I currently have 4 WD 4TB attached to a sonnet eSATA card and 3 WD 2 TB attached to a sonnet FW card and was having some issues with access times when saving to them. I decided to

  • Create a new view under a component in IC Webclient UI

    Hi , Can anyone tell how to create a new view under a component in IC Webclient UI. Regards, Sijo

  • Configuration steps for Infotype 0315

    Hi , My client need to maintain Time sheet data for there employees.for that they need to maintain Infotye 0315. Pls let me know what is infotype 0315  (Detailed description) & what are the configuration steps for infotype 0315.How to configure that

  • Halo reduction

    Has anyone figured out what the Halo Reduction brush is supposed to do? I have some images with terrible purple fringing where direct sunlight sparkles of water, which I thought were the perfect candidate to test this new feature of AP3. The effect I

  • Why do some applications hang up system

    After using some applications for awhile, they start hanging up system.  It's most noticable in Adobe Photoshop Elements (10),  It also happens in iPhoto.  I get the little spinning circle.   Many times I can't do a a force quit on the application or