SQL_TEXT

Hello

on the 11g R2, I run the following query:

Select SQL_TEXT from V$ SQLAREA WHERE SQL_ID = "0a912dzu15."

It seems to me that full sql_text is not displayed. I remember that before you run the query, we should do something like:

SET BIG = 40000

or similar.

You would kind of remind me of the correct syntax?

Thank you.

Select SQL_FULLTEXT

SQL > desc v$ sqlarea

Name

-----------------------

SQL_TEXT

SQL_FULLTEXT

....

Tags: Database

Similar Questions

  • How do I know the bind variables in sql_text from V$ sql

    I have query V$ sql, v$ sqlarea, V$ SQLTEXT, the spectacle of sql_text as select client_name to the customer where id =: B1;
    How can I get the value of: B1?
    I want to know the entire SQL command, what should I do?

    Kandi Sissi wrote:
    Not too sure, but check out the GV$ SQL_BIND_CAPTURE.

    Satish,
    I remember reading an anomaly that JL posted on this topic, I guess that it would be useful to know that there may be settings that can tweakthe behavior from this point of view, OP.
    http://jonathanlewis.WordPress.com/2008/07/24/bind-capture/
    Concerning
    Aman...

  • What is the "best way" to see all the 'hooks' that affect the database?

    Hi all

    I'm responsible for exporting all schemas using the data pump and then re - import the scehmas, yet once so we can reorganize the real table spaces.

    I know that this can be done using grid 12 c, but I'm not sure I want to use this feature for this task.

    Anyone who has used the feature of grids to 'keep the tables' and then re - organize them while they are still online?

    I'll have to finally make it to the PROD database and I am concerned about the "break" out of jobs, items, ect, ect.

    What is the "best way" to do a proper verification of all database objects and or work, that the export/import might pipe upward?

    As I did for example, a simple count on all objects and of course excludes "SYS and SYSTEM" and the County was in close 60 000 objects.

    How do I know all 'hooks' that are inside the database? What is the way that do you?

    Thank you

    Lady Allora.

    Hi, Justin.

    I think that's what I'm going the way of...

    Select os_username, username, OWNER, dba_audit_trail SQL_TEXT

    where rownum<>

    where username <> 'SYSTEM '.

    and also have different variations all asking questions them the same point of view...

    Modes of verification do you find useful?

    Also I'm using something like this as well.

    Select "check standard", sessionid,

    proxy_sessionid statementid, entryid, extended_timestamp, global_uid,

    username, client_id, null, os_username, userhost, os_process, terminal,

    instance_number, owner, obj_name, null, new_owner,

    new_name, action, action_name, audit_option, transactionid, returncode,

    SNA, comment_text, sql_bind, sql_text,

    obj_privilege, sys_privilege, admin_option, dealer, priv_used,.

    ses_actions, logoff_time, logoff_lread, logoff_pread, logoff_lwrite,

    logoff_dlock, session_cpu

    Of

    dba_audit_trail

    where rownum<>

    order extended_timestamp;

    Thank you

    Lady Allora.

  • boards of opt_estimate in the merge of refresh operations quick mview

    Hello

    in a system (Oracle 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production database) I'm trying to optimize, there are materialized views with "fast refresh on commit" and there are many queries to the following distribution:

    / * MV_REFRESH (MRG) * / MERGE INTO "XXX". "" WITH THE HELP OF YYY "" SNA$ ' (SELECT / * + OPT_ESTIMATE (QUERY_BLOCK MAX = 485387) * /...)

    "As far as I can see the queries show the structure explained in Alberto Dell's Oracle blog'Era ' quick refreshment of only materialized aggregate views with SUM - algorithm (in the section" Refresh for mixed-DML TMPDLT") - the best resource on refresh mview algorithms I know. But I could not find information on the setting of the OPT_ESTIMATE indicator. In the database, I see that the values in the indicator are changing:

    Select st.sql_id

    , substr (st.sql_text, instr (st.sql_text, 'OPT_ESTIMATE'), 40) sql_text

    St dba_hist_sqltext

    where st.sql_text like ' / * MV_REFRESH (MRG) * / MERGE INTO "XXX". » YYY » %'

    and...


    SQL_ID SQL_TEXT

    ------------- ----------------------------------------

    6by5cwg0v6zaf OPT_ESTIMATE (QUERY_BLOCK MAX = 485387) *.

    2b5rth5uxmaa2 OPT_ESTIMATE (QUERY_BLOCK MAX = 485387) *.

    4kqc15tb2hvut OPT_ESTIMATE (QUERY_BLOCK MAX = 490174) *.

    fyp1rn4qvxcdb OPT_ESTIMATE (QUERY_BLOCK MAX = 490174) *.

    a5drp0m9wt53k OPT_ESTIMATE (QUERY_BLOCK MAX = 407399) *.

    2dcmwg992pjaz OPT_ESTIMATE (QUERY_BLOCK MAX = 485272) *.

    971zzvq5bdkx6 OPT_ESTIMATE (QUERY_BLOCK MAX = 493572) *.

    46434kbmudkq7 OPT_ESTIMATE (QUERY_BLOCK MAX = 493572) *.

    4ukc8yj73a3h3 OPT_ESTIMATE (QUERY_BLOCK MAX = 491807) *.

    8k46kpy4zvy96 OPT_ESTIMATE (QUERY_BLOCK MAX = 491807) *.

    3h1n5db3vdugt OPT_ESTIMATE (QUERY_BLOCK MAX = 493547) *.

    5340ukdznyqr6 OPT_ESTIMATE (QUERY_BLOCK MAX = 493547) *.

    7fxhdph8ymyz8 OPT_ESTIMATE (QUERY_BLOCK MAX = 407399) *.

    15f3st5gdvwp3 OPT_ESTIMATE (QUERY_BLOCK MAX = 491007) *.

    083ntxzh8wnhg OPT_ESTIMATE (QUERY_BLOCK MAX = 491007) *.

    cg17yjx3qay5z OPT_ESTIMATE (QUERY_BLOCK MAX = 491452) *.

    5qt37uzwrwkgw OPT_ESTIMATE (QUERY_BLOCK MAX = 491452) *.

    byzfcg7vvj859 OPT_ESTIMATE (QUERY_BLOCK MAX = 485272) *.

    aqtdpak3636y5 OPT_ESTIMATE (QUERY_BLOCK MAX = 493572) *.

    dcrkruvsgpz3u OPT_ESTIMATE (QUERY_BLOCK MAX = 492226) *.

    7mmt5px6sd7xg OPT_ESTIMATE (QUERY_BLOCK MAX = 492226) *.

    9c6v714pbjvc0 OPT_ESTIMATE (QUERY_BLOCK MAX = 485336) *.

    fbpsz02yq2qxv OPT_ESTIMATE (QUERY_BLOCK MAX = 485336) *.

    0q04g2rh9j84y OPT_ESTIMATE (QUERY_BLOCK MAX = 491217) *.

    gp3u5d5702dpb OPT_ESTIMATE (QUERY_BLOCK MAX = 491638) *.

    9f35swtju24aa OPT_ESTIMATE (QUERY_BLOCK MAX = 491638) *.

    a70jwxnrxtfjn OPT_ESTIMATE (QUERY_BLOCK MAX = 491217) *.

    93mbf02cjq2ny OPT_ESTIMATE (QUERY_BLOCK MAX = 491217) *.

    Then of course the cardinalities in the OPT_ESTIMATE indication are not static here and the sql_id of foreign exchange as a result. And this change prevents me from using the basic lines of sql plan to gurantee a stable path (essentially to avoid the parallel operations for refresh, well operations that Parallels access for queries do not prevent). I did a quick check with 11.2.0.1 and see the same model here:

    drop materialized view t_mv;

    drop table t;

    create table t

    as

    Select rownum id

    , mod (rownum, 50) col1

    , mod (rownum, 10) col2

    , lpad ('* ', 50,' *') col3

    of the double

    connect by level < = 100000;

    exec dbms_stats.gather_table_stats (user, 't')

    Create materialized view log on t with rowid (id, col1, col2, col3) including the new values;

    Create materialized view t_mv

    quickly refresh on validation

    as

    Select col1

    sum (col2) sum_col2

    count (*) NTC

    count (col2) cnt_col2

    t

    Col1 group;

    Update t set col2 = 0 where col1 = 1;

    commit;

    SQL_ID, 4gnafjwyvs79v, number of children 0

    -------------------------------------

    / * MV_REFRESH (MRG) * / MERGE IN 'TEST '. "" T_MV ""$SNA"WITH THE HELP OF SELECT (SELECT

    / * + OPT_ESTIMATE (QUERY_BLOCK MAX = 1000) * / "DLT$ 0. "" COL1 ""GB0. "

    SUM (DECODE ("DLT$ 0". "DML$ $"(, 'I', 1,-1) * DECODE ("DLT ($0". " ("" COL2 ").

    (NULL, 0, 1)) 'D0', SUM (DECODE ("DLT$ 0". "DML$ $"(, 'I', 1,-1)) 'D1', "

    NVL (SUM (DECODE ("DLT$ 0". "DML$ $"(, 'I', 1,-1) * ("DLT$ 0". " ((("" COL2 ")), 0)

    'D2' FROM (SELECT CHARTOROWID (' MAS$ ".)) ("' M_ROW$ $') RID$,.

    "MAS$". " "COL1", "MAS$". "' COL2 ', DECODE (" MAS$ ".) OLD_NEW$ $, 'N', ' (I ' 'd').

    DML$ $, "MAS$". "" DMLTYPE$ $"" DMLTYPE$ $', 'TEST '. "" MLOG$ _T "" MAS$ ".

    WHERE "MAS$". XID$ $ =: 1) 'DLT$ 0' GROUP BY 'DLT$ 0. ("' COL1 ')" AV$ "ON

    (SYS_OP_MAP_NONNULL ("SNA$".)) ("' COL1 ') = SYS_OP_MAP_NONNULL (" AV$ ".) (("" GB0 '))

    WHEN MATCHED THEN UPDATE SET "SNA$". "CNT_COL2"= "$SNA". «CNT_COL2 "+" AV$ ".»

    'D0', '$SNA '. "CNT"= "$SNA". «CNT "+" AV$ ".» "' D1 ',.

    "SNA$". " SUM_COL2 "= DECODE (" SNA$ "". ")" CNT_COL2 "+" AV$ ".» D0', 0, NULL, NVL ("SNA$".)

    ("SUM_COL2", 0) + AV$ «» ("' D2 ') DELETE WHERE (" SNA$ ".) ("' CNT ' = 0) IS NOT

    MATCHED THEN INSERT ("SNA$".) "" COL1 ","$SNA ". "" CNT_COL2 ","$SNA ". "" CNT ",.

    Hash value of plan: 2085662248

    -----------------------------------------------------------------------------------

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

    -----------------------------------------------------------------------------------

    |   0 | MERGE STATEMENT |         |       |       |    24 (100) |          |

    |   1.  MERGE | T_MV |       |       |            |          |

    |   2.   VIEW                  |         |       |       |            |          |

    |*  3 |    OUTER HASH JOIN |         |    40.  4640 |    24 (9) | 00:00:01 |

    |   4.     VIEW                |         |    40.  2080.    20 (5) | 00:00:01 |

    |   5.      GROUP SORT BY |         |    40.  1640 |    20 (5) | 00:00:01 |

    |*  6 |       TABLE ACCESS FULL | MLOG$ _T |    40.  1640 |    19 (0) | 00:00:01 |

    |   7.     MAT_VIEW FULL ACCESS | T_MV |    50.  3200 |     3 (0) | 00:00:01 |

    -----------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    3 - access (SYS_OP_MAP_NONNULL ("SNA$".)) ("' COL1 ') = SYS_OP_MAP_NONNULL (" AV$ ".) "G

    B0'))

    6 - filter("MAS$".") XID$ $"(=:1)"

    Note

    -----

    -dynamic sample used for this survey (level = 2)

    So I see an OPT_ESTIMATE (QUERY_BLOCK MAX = 1000) and this estimate seems to be fairly stable when I change the number of lines, number of blocks, use partitioning etc. I checked a trace with Event 10046 but didn't source the value 1000. I also disabled the comments of cardinality ("_optimizer_use_feedback" = false) and there is no profile sql in my system (according to dba_sql_profiles) - but the OPT_ESTIMATE is still there.

    So the question is: is there something known about values used in the OPT_ESTIMATE indication for the materialized view fast refresh operations? Thanks in advance for your contributions.

    Concerning

    Martin Preiss

    Martin Preiss wrote:

    In regard to point 1: initially as a partitioned table starting with K 1000 lines, then 100K, then 10K, I created my test T table (using my old example of Blog Oracle MP: Materialized View Fast refresh): in all cases, I got OPT_ESTIMATE (QUERY_BLOCK MAX = 1000). My first problem in this context is that I did not come with a model showing different OPT_ESTIMATE values - as I see them in the prod system.

    Using the sql Profiler and the force_match option looks promising - I'll check if I can use them here.

    Concerning

    Martin

    Hi Martin,

    but perhaps the OPT_ESTIMATE indicator is based on stats of the MLOG or MV table, where my question. Since this is the option to 'MAX' of OPT_ESTIMATE (limit the maximum number of rows for this query block) the 1000 resembles 'low' default value is used if the stats are missing or the MLOG / MV table less than 1000 lines?

    Randolf

  • Calculation of the time wall of a SQL query.

    Hello

    While trying to discover the time of running a SQL query (wall time) I read in one place that CPU_TIME/EXECUTIONS of v$ SQLAREA, is the precise runtime we can come close to.

    I can't use "set timing on ' or 'DBMS_UTILITY. GET_TIME' that I need to extract the execution time of the story because the query will be drawn to an end, and I need to know how long it took to DB level and compare it with the end time before calculating the % of time used in the DB level total.

    Maybe another way to track sessions and the user TKPORPOF but now I donot want to take the help of the ADMINISTRATOR at this initial stage.

    Is CPU_TIME/EXECUTIONS of v$ SQLAREA where (SQL_TEXT) AS "SELECT... OF... %'; should be enough?

    user2925917, yes as Brian already answered your understanding as posted above seems correct.  Except in the case where there has been only a running query you will download an average time.  The problem with averages is that one or two unusual executions that can skew the average, but in most cases the average will be probably fairly accurate.

    - -

    HTH - Mark D Powell.

  • Cursor_Sharing = Force and queries with literal comparisons forcing FTS

    Hi all

    I have the following scenario:

    • Oracle 11.2.0.3
    • A 3rd party application, requiring cursor_sharing = TRUE
    • A table (T2310) with an indexed field (C1000000161), which has no duplicate values
    • Cause the Mode Cache = force (don't think it's relevant in the present case, but its here to justify its appearance in the explain output)

    In this scenario, the 3rd party application run queries like the one below (I have to use the trick here, given that the explanation will not show the FTS):

            SQL> select /*+ GATHER_PLAN_STATISTICS */ C1000000161 
            > from aradmin.T2310 
            > where C1000000161 = 'INC000002137945' or ('a' = 'b');
    

    This type of query will eventually force a full table scan:

        SQL> SELECT * FROM table(DBMS_XPLAN.DISPLAY_CURSOR(FORMAT=>'ALLSTATS LAST'));
    
        PLAN_TABLE_OUTPUT
        --------------------------------------------------------------------------------------------------------------------
        SQL_ID  f3njwvkb0yf1x, child number 0
        -------------------------------------
        select /*+ GATHER_PLAN_STATISTICS */ C1000000161 from
        aradmin.T2310 where C1000000161 = :"SYS_B_0" or (:"SYS_B_1"
        = :"SYS_B_2")
    
        Plan hash value: 1862236576
    
        --------------------------------------------------------------------------------------------------------------------
        | Id  | Operation          | Name                       | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |
        --------------------------------------------------------------------------------------------------------------------
    
        PLAN_TABLE_OUTPUT
        --------------------------------------------------------------------------------------------------------------------
        |   0 | SELECT STATEMENT   |                            |      1 |        |      0 |00:03:00.20 |    3964K|    161K|
        |   1 |  RESULT CACHE      | bkhyzz7n945syc4numpbs27y20 |      1 |        |      0 |00:03:00.20 |    3964K|    161K|
        |*  2 |   TABLE ACCESS FULL| T2310                      |      1 |  44030 |      0 |00:03:00.20 |    3964K|    161K|
        --------------------------------------------------------------------------------------------------------------------
    
        Predicate Information (identified by operation id):
        ---------------------------------------------------
    
           2 - filter((:SYS_B_1=:SYS_B_2 OR "T2310"."C1000000161"=:SYS_B_0))
    
        Result Cache Information (identified by operation id):
    
        PLAN_TABLE_OUTPUT
        --------------------------------------------------------------------------------------------------------------------
        ------------------------------------------------------
    
           1 -
    

    As we can see in the explanation, literals are replaced with bind variables, and I think that it is forcing the FTS. If you remove the literal comparison, the index is used as intended.

    So my question is: is it possible to avoid this behavior on the side of the database?

    Thank you!

    As you say, we have two possible plans, we want to either that each row in the table or we want to use our predicate of the column. If we let the plan for both possibilities should have acceptable performance for the typical case (: SYS_B_1<>: SYS_B_2) and correct the results in the case of equality.

    If sql is rewritable I would do something like

    Select / * + GATHER_PLAN_STATISTICS * / C1000000161
    of t2310
    where C1000000161 =: b1
    and (: b2 <> : b3 or: b2 is null or: b3 is null)
    Union of all the
    Select C1000000161
    of t2310
    where: = b2: b3;

    The or_expand indicator (undocumented, but I find it more easy to set use_concat) could be useful to force the regime to take this shape without having to rewrite the query.

    create table t2310 (pk_col, C1000000161 VARCHAR2 (100 CHAR), constraint t2310_pk primary key (pk_col));
    create index t2310_161 on t2310 (C1000000161);
    Insert into t2310
    Select rownum, dbms_random.string ('U', 3) | To_char(rowNum,00000000000000)
    of the double
    connect by rownum<=>
    commit;
    exec dbms_Stats.gather_Table_stats (user, 't2310')
    ALTER session set cursor_sharing = force;

    Select / * + OR_EXPAND(t2310 C1000000161) GATHER_PLAN_STATISTICS * / C1000000161
    of t2310
    where C1000000161 = 'INC000002137946' or ("a" = "b");
    SELECT * FROM table (DBMS_XPLAN. DISPLAY_CURSOR (FORMAT-ONLINE 'ALLSTATS LAST'));

    Hash value of plan: 928588817

    -------------------------------------------------------------------------------------------
    | ID | Operation | Name | Begins | E - lines. A - lines.  A - time | Pads |
    -------------------------------------------------------------------------------------------
    |  0 | SELECT STATEMENT |          |      1.        |      0 | 00:00:00.01 |      2.
    |  1.  CONCATENATION.          |      1.        |      0 | 00:00:00.01 |      2.
    |*  2 |  INDEX RANGE SCAN | T2310_161 |      1.      6.      0 | 00:00:00.01 |      2.
    |*  3 |  FILTER |          |      1.        |      0 | 00:00:00.01 |      0 |
    |*  4 |    TABLE ACCESS FULL | T2310 |      0 |  99994 |      0 | 00:00:00.01 |      0 |
    -------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    2 - access("C1000000161"=:SYS_B_0)
    3 - filter(:SYS_B_1=:SYS_B_2)
    4 filter (LNNVL ("C1000000161" =: SYS_B_0))

    Now, you can use a plan for this sql database attach to the sql application:

    Select / * + GATHER_PLAN_STATISTICS * / C1000000161
    of t2310
    where C1000000161 = 'INC000002137946' or ("a" = "b");
    SELECT * FROM table (DBMS_XPLAN. DISPLAY_CURSOR (FORMAT-ONLINE 'ALLSTATS LAST'));

    Hash value of plan: 1862236576

    -------------------------------------------------------------------------------------
    | ID | Operation | Name | Begins | E - lines. A - lines.  A - time | Pads |
    -------------------------------------------------------------------------------------
    |  0 | SELECT STATEMENT |      |      1.        |      0 | 00:00:00.03 |    248.
    |*  1 |  TABLE ACCESS FULL | T2310 |      1.  1006 |      0 | 00:00:00.03 |    248.
    -------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    1 Filter ((: SYS_B_1 =: SYS_B_2 or "C1000000161" =: SYS_B_0))

    @sql_find t2310

    CHILD_NUMBER PLAN_HASH_VALUE LAST_ACTIVE_TIME EXECUTIONS SQL_TEXT SQL_ID
    ------------- ------------ --------------- ------------------- ---------- ----------------------------------------------------------------------------------------------------
    34k49g78s1w5w 453626665 04/01/2016 0 22:55:11 1 Select / * + no_parallel_index (t, "T2310_PK") cursor_sharing_exact use_weak_name_resl dyn dbms_stats
    cnsa5smf77n8w 2274106110 04/01/2016 0 22:55:11 1 Select / * + no_parallel_index (t, "T2310_161") use_weak_name_resl cursor_sharing_exact, dbms_stats dy
    1cyhgv72abcf5 928588817 04/01/2016 0 22:55:11 1 Select / * + OR_EXPAND(t2310 C1000000161) GATHER_PLAN_STATISTICS * / t2310 C1000000161 where C1000
    gv84zvt3hagrk 1862236576 04/01/2016 0 22:55:11 1 Select / * + GATHER_PLAN_STATISTICS * / C1000000161 t2310 where C1000000161 =: 'SYS_B_0' or (: "SYS)
    2z5dv340ttwc3 0 0 01/04/2016-22:55:11 1 BEGIN dbms_Stats.gather_Table_stats (user, 't2310'); END;

    number of plans of var
    exec: plans: = dbms_spm.load_plans_from_cursor_cache(sql_id=>'gv84zvt3hagrk',plan_hash_value=>1862236576)

    print plans
    PLANS
    --------
    1

    Select the SQL_HANDLE column, plan_name, sql_Text dba_sql_plan_baselines;

    SQL_HANDLE PLAN_NAME SQL_TEXT
    ------------------------------ ------------------------------ ---------------------------------------------------------
    SQL_32cad750b449f08a SQL_PLAN_35kqra2u4mw4a24696a58 select / * + GATHER_PLAN_STATISTICS * / C1000000161
    of t2310
    where C1000000161 =
                   
                   
    exec: plans: = dbms_spm.load_plans_from_cursor_cache (sql_id-online '1cyhgv72abcf5', plan_hash_value-online 928588817, sql_handle => 'SQL_32cad750b449f08a')
    Select the SQL_HANDLE column, plan_name, sql_Text dba_sql_plan_baselines;
    SQL_HANDLE PLAN_NAME SQL_TEXT
    ------------------------------ ------------------------------ -----------------------------------------------------
    SQL_32cad750b449f08a SQL_PLAN_35kqra2u4mw4a24696a58 select / * + GATHER_PLAN_STATISTICS * / C1000000161
    of t2310
    where C1000000161 =

    SQL_32cad750b449f08a SQL_PLAN_35kqra2u4mw4af7b73bde select / * + GATHER_PLAN_STATISTICS * / C1000000161
    of t2310
    where C1000000161 =

    exec: plans: = dbms_spm.alter_sql_plan_baseline(sql_handle=>'SQL_32cad750b449f08a',plan_name=>'SQL_PLAN_35kqra2u4mw4a24696a58',attribute_name=>'enabled',attribute_value=>'NO')

    Select / * + GATHER_PLAN_STATISTICS * / C1000000161
    of t2310
    where C1000000161 = 'INC000002137946' or ("a" = "b");
    SELECT * FROM table (DBMS_XPLAN. DISPLAY_CURSOR (FORMAT-ONLINE 'ALLSTATS LAST'));

    Hash value of plan: 928588817

    -------------------------------------------------------------------------------------------
    | ID | Operation | Name | Begins | E - lines. A - lines.  A - time | Pads |
    -------------------------------------------------------------------------------------------
    |  0 | SELECT STATEMENT |          |      1.        |      0 | 00:00:00.01 |      2.
    |  1.  CONCATENATION.          |      1.        |      0 | 00:00:00.01 |      2.
    |*  2 |  INDEX RANGE SCAN | T2310_161 |      1.      6.      0 | 00:00:00.01 |      2.
    |*  3 |  FILTER |          |      1.        |      0 | 00:00:00.01 |      0 |
    |*  4 |    TABLE ACCESS FULL | T2310 |      0 |  99994 |      0 | 00:00:00.01 |      0 |
    -------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    2 - access("C1000000161"=:SYS_B_0)
    3 - filter(:SYS_B_1=:SYS_B_2)
    4 filter (LNNVL ("C1000000161" =: SYS_B_0))

    Note
    -----
    -Basic plan SQL SQL_PLAN_35kqra2u4mw4af7b73bde used for this statement

    As you can see, line 4 is running at all because of the filter in line 3 (start = 0 where id = 4)

  • Query not in source code

    Hello

    during the execution of a package, I noticed that the following query takes to run:

    select /*+ all_rows */ count(1) from MYTABLE where MY_ID = :1
    

    The problem is that I can't find this code in my source; is perhaps a query fired by Oracle to check one constraint (foreign key) with another table? Indeed, on MYTABLE it is a foreign key on MY_ID.

    Thank you

    Igor

    I was under the impression made Oracle a simple select 1 child where rownum<2 and="" parentkey="">

    I just did a quick check and turns that it uses the (*) count, strange indeed!

    SQL > select * from v version $;

    BANNER                                                                               CON_ID
    -------------------------------------------------------------------------------- ----------
    Database Oracle 12 c Enterprise Edition Release 12.1.0.2.0 - 64 bit Production 0
    PL/SQL Release 12.1.0.2.0 - Production 0
    CORE 12.1.0.2.0 Production 0
    AMT for 64-bit Windows: Version 12.1.0.2.0 - Production 0
    NLSRTL Version 12.1.0.2.0 - Production 0

    SQL > get foreign_key_demo.sql
    1 alter session set nls_date_format = "dd/mm/yyyy hh24:mi:ss";
    2 alter session set optimizer_dynamic_sampling = 0;
    3 create the parent_table table (col1 number primary key, col2 varchar2 (30 CHAR));
    4 create the child_Table table (primary key number col1, col2 number, key foreign forced child_table_fk (col2) refers to parent_table (col1), col3 varchar2 (30 char));
    5 insert into parent_Table select rownum, 'x' from dual connect by level<>
    6 insert into child_table select rownum, mod (rownum, 10) + 1, 'x' from dual connect by rownum<>
    7 validation;
    8. SELECT sysdate FROM dual;
    9 remove parent_table where rownum<>
    break 10
    11 create index child_table_fki01 on child_table (col2);
    12 sysdate SELECT FROM dual;
    13 * remove parent_table where rownum<>
    SQL > get sql_find
    1 col sql_Text for a100
    2. SELECT * FROM
    3 (SELECT sql_id
    4, child_number
    5, last_active_time
    6, executions
    7, SUBSTR(sql_text,1,100) sql_text
    8. FROM v$ sql
    9. WHERE upper (sql_text) not like ' % $ SQL %.
    10 AND upper (sql_text) AS UPPER('%&1%')
    11 last_active_time ORDER BY DESC
    12)
    13 * WHERE rownum<>

    Modified session.
    Modified session.
    Table created.
    Table created.
    10 rows created.
    100 rows created.
    Validation complete.
    SYSDATE
    -------------------
    25/11/2015-13:10:18
    Remove parent_table where rownum<>
    *
    ERROR on line 1:
    ORA-02292: integrity constraint (ANDY. CHILD_TABLE_FK) violated - book of the foundling

    The index is created.
    SYSDATE
    -------------------
    25/11/2015-13:10:25
    Remove parent_table where rownum<>
    *
    ERROR on line 1:
    ORA-02292: integrity constraint (ANDY. CHILD_TABLE_FK) violated - book of the foundling

    -Pause
    SQL > @sql_find parent_table
    CHILD_NUMBER LAST_ACTIVE_TIME EXECUTIONS SQL_TEXT SQL_ID
    ------------- ------------ ------------------- ---------- ----------------------------------------------------------------------------------------------------
    ct95ubmvnsnbr 0 25/11/2015 13:10:18 1 insert in parent_Table select rownum, 'x' from dual connect by level<>
    ggbcat7maxjut 0 25/11/2015-13:10:18 1 CREATE UNIQUE INDEX 'ANDY '. "" SYS_C0010009 "on"ANDY. " ""("COL1") NOPARALLEL PARENT_TABLE "
    gtn0x816p6nh8 0 25/11/2015-13:10:18 1 of LOCK TABLE IN SHARE NOWAIT MODE "PARENT_TABLE"
    6ra4fg43v38p8 0 25/11/2015 13:10:18 1 remove parent_table where rownum<2>

    SQL > @sql_find child_table

    CHILD_NUMBER LAST_ACTIVE_TIME EXECUTIONS SQL_TEXT SQL_ID
    ------------- ------------ ------------------- ---------- ----------------------------------------------------------------------------------------------------
    71kxuhwfzp372 0 25/11/2015 13:10:18 1 insert into child_table select rownum, mod (rownum, 10) + 1, 'x' from dual connect by rownum<>
    acgmknbxt177t 0 25/11/2015 13:10:18 1 Select / * + all_rows * / count (1) "Andy." "' CHILD_TABLE ' where 'COL2' =: 1
    09qnag92wuwr6 0 25/11/2015-13:10:18 1 CREATE UNIQUE INDEX 'ANDY '. "" SYS_C0010010 "on"ANDY. " "CHILD_TABLE"("COL1") NOPARALLEL "

    -After race full
    SQL > @sql_find parent_table

    CHILD_NUMBER LAST_ACTIVE_TIME EXECUTIONS SQL_TEXT SQL_ID
    ------------- ------------ ------------------- ---------- ----------------------------------------------------------------------------------------------------
    6ra4fg43v38p8 0 25/11/2015 13:10:25 1 remove parent_table where rownum<>
    ct95ubmvnsnbr 0 25/11/2015 13:10:18 1 insert in parent_Table select rownum, 'x' from dual connect by level<>
    ggbcat7maxjut 0 25/11/2015-13:10:18 1 CREATE UNIQUE INDEX 'ANDY '. "" SYS_C0010009 "on"ANDY. " ""("COL1") NOPARALLEL PARENT_TABLE "
    gtn0x816p6nh8 0 25/11/2015-13:10:18 1 of LOCK TABLE IN SHARE NOWAIT MODE "PARENT_TABLE"

    SQL > @sql_find child_table

    CHILD_NUMBER LAST_ACTIVE_TIME EXECUTIONS SQL_TEXT SQL_ID
    ------------- ------------ ------------------- ---------- ----------------------------------------------------------------------------------------------------
    0va5scxgqstmw 0 25/11/2015-13:10:25 1 TABLE LOCK IN SHARE MODE NOWAIT ' CHILD_TABLE'
    71kxuhwfzp372 0 25/11/2015 13:10:18 1 insert into child_table select rownum, mod (rownum, 10) + 1, 'x' from dual connect by rownum<>
    acgmknbxt177t 0 25/11/2015 13:10:18 1 Select / * + all_rows * / count (1) "Andy." "' CHILD_TABLE ' where 'COL2' =: 1
    09qnag92wuwr6 0 25/11/2015-13:10:18 1 CREATE UNIQUE INDEX 'ANDY '. "" SYS_C0010010 "on"ANDY. " "CHILD_TABLE"("COL1") NOPARALLEL "

    As you can see, after the addition of the index, the select count (*) fires is no longer. The lock table statement is due to the creation of indexes.

    -edit

    After reading this I find a bit strange that implicit unique index creations are in v$ sql but not the sole explicit is not. The problem with simple tests, is that it always shows me that things are not simple.

  • physical_read_requests &gt; disk_reads

    Hello

    I was wondering about sqls in v$ sql where physical_read_requests vs disk_reads.
    I know when instead it is likely reading diluvium, but I'm trying to understand some SQLs I see with, for example, 900 k physical_read_requests and disk 4 bed.

    Query your database for:

    select sql_id, disk_reads, physical_read_requests
    from v$sql 
    where physical_read_requests > disk_reads
    /
    
    SQL_ID        DISK_READS PHYSICAL_READ_REQUESTS
    ------------- ---------- ----------------------
    fd9qbhuy1hgrx          0                     14
    2xucgknahj256        167                    181
    934ur8r7tqbjx          1                     15
    934ur8r7tqbjx          0                      7
    fpvps147hqh7g          1                      8
    89p81j073yhv8         26                     40
    akj15bfw7ypt4         41                     48
    bn4b3vjw2mj3u          0                     35
    


    Any clue?

    Salman Qureshi says:

    I here speculates that if even block (for which a physical read request is issued to a SQL), some other SQL/session could also have requested a physical read (and a reading of disc) - occupied buffer waiting happen also. This disc has played for this sql would not increase (because the data has already been read form the disc at the request of the other sql/session). So in this case, physical_read_request for this SQL has increased, but not disk_read.

    Good idea, but I don't think it should work like that.

    The second session who wanted to read the block would be the cache buffers chains get found block one buffer that takes this block pinned exclusively in the State "be read from disk", so do not try to read it, so should not change either of the two stats. (He makes a good point that the session not next - but it's out of scope for this thread.)

    I've been speculating in the sense of an instrumentation error - a task update a single statistic, but not the other. The possibilities include:

    readings for dynamic sampling

    readings of global temporary tables

    readings of materialized "with" subqueries

    readings of tablespace temp for mergers of sorts/axe/bitmap

    journey live readings

    readings of the flash cache

    Exadata ' no data not necessary "read the applications

    However, a much simpler explanation is that not all the readings are bed data block, so eventually the counties (for example) physical_read_requests controlfile read requests while disk_reads number just blocks to read data files.  Try this:

    SQL > select disk_reads, physical_read_requests, sql_text from v$ sql where sql_id = "adnu4f081dhar";

    DISK_READS PHYSICAL_READ_REQUESTS SQL_TEXT

    ---------- ---------------------- --------------------------------------------------------------------------------

    0 28 select current_scn in the database of v$

    SQL > select current_scn from v$ database;

    CURRENT_SCN

    -----------

    1.2670E + 13

    SQL > select disk_reads, physical_read_requests, sql_text from v$ sql where sql_id = "adnu4f081dhar";

    DISK_READS PHYSICAL_READ_REQUESTS SQL_TEXT

    ---------- ---------------------- --------------------------------------------------------------------------------

    0 35 select current_scn in the database of v$

    SQL > select current_scn from v$ database;

    CURRENT_SCN

    -----------

    1.2670E + 13

    SQL > select disk_reads, physical_read_requests, sql_text from v$ sql where sql_id = "adnu4f081dhar";

    DISK_READS PHYSICAL_READ_REQUESTS SQL_TEXT

    ---------- ---------------------- --------------------------------------------------------------------------------

    0 42 select current_scn in the database of v$

    The declaration card 7 physical_read_requests and not disk_reads on each execution and at the same time I see 7 waits 'control file sequential read '.

    Concerning

    Jonathan Lewis

  • How to see the sql on the tables verified statements?

    Hi all

    I just check schema as the following comment run

    AUDIT UPDATE TABLE DELETE TABLE INSERT TABLE BY user1, user2 BY ACCESS;

    However, I could not find the SQL statements.

    SELECT A.TIMESTAMP, A.* DE DBA_AUDIT_TRAIL A

    Username = ' USER1'

    Also, this does not work, it shows empty

    select sql_text from sys. aud$ obj$ nom = « TAB_PROJELOG »


    Oracle Database 11 g Release 11.2.0.4.0 - 64 bit Production

    • db

      Redirect audit records to the database audit trail (the SYS.AUD$ table), except for records that are always written in the track operating system audit. Use this setting for a general database for administration.

      If the database is started in read-only mode with AUDIT_TRAIL defined on db , then affects the Oracle database internally AUDIT_TRAIL to os . Check the log of alerts for details.

    • db, extended

      Performs all the actions of AUDIT_TRAIL = db and fulfills also the bind SQL and SQL CLOB type text columns of the SYS.AUD$ table, when it is available. These two columns are filled only when specified.

      If the database is started in read-only mode with AUDIT_TRAIL defined on db, extended , then affects the Oracle database internally AUDIT_TRAIL to os . Check the log of alerts for details.

    https://docs.Oracle.com/CD/E11882_01/server.112/e40402/initparams017.htm#REFRN10006

  • How to find who holds a SQL lock when its not v$ session.sql_id and v$ session.prev_sql_id

    Hi all

    Looking a little nudge in the right direction on a strange problem with blocking locks in our database of BSE...

    We occasionally will blocking locks in our EBS 12.1.3 database (11.2.0.4 CARS on OEL5).   I can easily determine the INST_ID select and SID that keeps the lock with this:

    Select final_blocking_instance, final_blocking_session from gv$ session where lockwait is not null;

    and can use these results to find the specific object being blocked by querying a gv$ locked_object where session_id = xxx and INST_ID select = xxx.   These sessions blocker are generally inactive to an event of "SQL * Net client message"-while they seem to be connected to the database users who need simply to commit or rollback transactions.   Usually, when I see this type of behavior, the specific application involved in the unresolved external transactions is easy to find by taking the SQL_ID (or sometimes the PREV_SQL_ID) value of gv$ session and questioning gv$ sql.  I can then use this information to better understand what users are trying to accomplish and help them understand what they need to change to avoid the deadlock problem.

    But recently, we have integrated the add-on of Oracle content management and it seems to have added (I suspect indirectly) triggers for many forms EBS our users work in.  Now that we know these "locks blocking inactive form" - and the SQL_ID value is zero and related PREV_SQL_ID sql_text is

    SELECT * FROM AXF_COMMANDS_SYN WHERE FORMID =: b1 AND (MENUTYPE = 'SPÉCIAL' MENUTYPE or = "ZOOMANDSPECIAL") AND AXF_COMMANDS_SYN. SPECIAL 'n' IS NOT NULL


    Although I can see SGS $ locked_object both the text of the SQL being run by sessions which blocked the blocking the locks held by the session is on an object (for example RA_CUSTOMER_TRX_ALL) that does not seem to be at all related to AXF_COMMANDS_SYN.   The AXF schema has been added as part of the deployment of content management.


    So, my thought is that a different cursor open (previous) held by the session is the real unresolved SQL that maintains the lock.  Is there a way to determine the SQL_ID of this query "indirectly" from gv$ locked_object / gv$ transaction, gv$ open_cursor, etc.?  I can determine what is the problem and what user, we need to talk to him - but I would really like to find the exact SQL that is involved.   I am also to establish if the new behavior is somehow contributing to locking problems blocking or just 'a Kipper"- and I think I know which statement SQL Gets the lock will help me to move forward with the investigation.  I'm sure I could find this info by tracing the blocking - session but the problem occurs rarely, and I'm not able to determine which trace session until it is too late... :-)


    Any recommendations would be appreciated, and my apologies for the long post...









    A session may issue a followed LMD of 5 requests without issuing a commit.

    Another session may be attempting a DML when the 5th request session above is running.  Querying V$ session for the first session SQL_ID or PREV_SQL_ID wouldn't you say the first SQL DML.

    You can walk backwards through V$ ACTIVE_SESSION_HISTORY (if you have the License Pack diagnosis) and determine all SQL_IDs of this first session if they did get captured in V$ ACTIVE_SESSION_HISTORY or DBA_HIST_ACTIVE_SESS_HISTORY.  (Attention: not all SQLs are captured - particularly short-lived SQLs can't get captured)

    Hemant K Collette

  • Why do I own this blocking session / blocked

    Oracle 11.2.0.4 SE a 64-bit

    Oracle Linux 5

    We have a task that runs every 5 minutes to detect blocking sessions / blocked.  When it detects an email with the details is sent.  Conduct of query is the following:

    select NVL(s1.username,''null'') username1,
                    s1.machine machine1,
                    s1.sid sid1,
                    s1.osuser osuser1,
                    s1.program program1,
                    lo.object_id locked_object,
                    NVL(s2.username,''null'') username2,
                    s2.machine machine2,
                    s2.sid sid2,
                    s2.osuser osuser2,
                    s2.program program2,
                    sqlt.sql_text sql_text2
             from   v$lock l1,
                    v$session s1,
                    v$lock l2,
                    v$session s2,
                    v$locked_object lo,
                    v$sqltext sqlt
             where s1.sid=l1.sid
               and s2.sid=l2.sid
               and l1.BLOCK=1 and l2.request > 0
               and l1.id1 = l2.id1
               and l2.id2 = l2.id2
               and s1.sid = lo.session_id
               and s2.sql_address = sqlt.address
               and s2.sql_hash_value = sqlt.hash_value
               and sqlt.piece = 0
    

    Normally things are fairly quiet except on the occasion one of my power forgot to engage users.  But last week I started to have notification that a session belonging to me (ESTEVENS) was blocking one or more sessions held by me.  Still, he arrives at 21:00 and fades within 5 minutes before the next review.  The sql code associated with the blocked session is always the same.  Here is a representative sample, with company data obscured.

    Block user - ESTEVENS

    Machine - myserver.mycompany.org

    SID - 433

    OSUSER - oracle

    -PROGRAM [email protected] (J001)

    OBJID - 12451

    Blocked user - ESTEVENS

    Machine - myserver.mycompany.org

    SID - 200

    OSUSER - oracle

    -Program [email protected] (J002)

    SQL: UPDATE HS_FDS_CLASS_DATE SET FDS_CLASS_DATE = SYSDATE WHERE FDS_

    By comparing the time of the block and SIDS reported with DBA_SCHEDULER_JOB_RUN_DETAILS content, I was able to follow some scheduled tasks 'load '.  These jobs do a SELECT... IN... OF < db_link >.  Because the table is locked is HS_FDS_CLASS_DATE, I found notes 1536085.1 describing a bug with the use frequent or simultaneous to a db_link, supposed to be fixed in 11.2.0.4 but my experience says otherwise.  However, I can deal with all that.

    But my real question is how to get my username attached to these sessions?

    Understand your question, I hope...

    It happened to me, that if I use my "DBA1' to create one job to another user"USER1", my user name is indicated as the USER name in the session, but 'The ANALYSIS of the USER' are the owner of the task.

    I think it's normal, but I still don't know why.

    Edit: Duh! It seems that it is documented Overview of job creation

    Because no destination_name attribute is specified, the task runs on the (local) database of origin. The job runs as the user who created the work.

    Kind regards

    Juan M

  • 12 c OEM Error rendering element. Exception: ORA-00942: table or view does not exist

    Hi gurus,

    Need your help to resolve ORA-00942 in OEM 12 c. I am planning Long running with a custom query SQL report and get ORA - error.


    I followed the instructions of MOS ' how to create a Custom Information Publisher report listing the current status of all targets (Doc ID 1682668.1). I also gave all possible permissions for mgmt._view


    Grants-

    Grant select on gv_$ ACTIVE_SESSION_HISTORY to mgmt_view;

    Grant select on gv_$ SQLAREA to mgmt_view;

    Custom - query

    SELECT *.

    OF (WITH test (schema_name, machine, sql_id, executions, elapsed_time, sql_text)

    AS (SELECT b.parsing_schema_name,

    a.machine,

    a.sql_id,

    b.executions,

    To_char (MAX (b.elapsed_time) * 0,000001,)

    ' (999999999999999.999').

    LIKE "time (in seconds)."

    B.SQL_TEXT

    OF ACTIVE_SESSION_HISTORY $ Gv, Gv$ SQLAREA B

    WHERE A.SAMPLE_TIME > = SYSDATE - 1

    AND A.SQL_ID = B.SQL_ID

    AND b.executions > 5

    GROUP OF b.parsing_schema_name, a.machine, a.sql_id, b.executions, B.SQL_TEXT

    ORDER BY DESC 4)

    SELECT DISTINCT

    schema_name,

    machine,

    sql_id,

    SUM (executions) as TOTAL_EXECUTIONS,

    SUM (elapsed_time) as TOTAL_ELAPSED_TIME,

    To_char (SUM (elapsed_time) / SUM (executions), ' 999999999999999.999' ") as AVG_RUN_TIME,

    sql_text

    TEST where lower (sql_text) not like '% select%genre.itemname%genre.itemvalue%retailerslogourl%rights_token%md_basic_info_genre%' and sql_text not like '% Analyze % '.

    GROUP BY schema_name, sql_id, machine, sql_text

    ORDER BY DESC 4)

    WHERE ROWNUM < = 20

    Compared to the 10 g report and reading different articles, type target_user_table_from_sql element is missing from 12 c. Do we need to create 12 c or any other parameter that we must follow in 12 c.

    Thanks in advance.

    Kind regards

    Nikhil Mehta.

    Hi all

    I could solve the problem by following the steps below.

    (1) in order to generate reports on the target DB, inserts under folders sysman schema.

    insert into sysman.mgmt_ip_report_elem_def values ('target_user_table_from_sql', 'database_target_type', 'target_user_table_from_sql', 'oracle.sysman.db.util.reports.TableTargetRenderController', 0, NULL, 'EM', NULL, '10.2.0.1.0');

    Insert SYSMAN. MGMT_IP_ELEM_PARAM_CLASSES (ELEMENT_TYPE_NLSID, ELEMENT_PARAM_CLASS, ELEMENT_NAME_NLSID, DISPLAY_ORDER) values ('target_user_table_from_sql', 'database_target_type ','oracle.sysman.eml.ip.render.elem.HeaderParamController ', 1);

    Insert SYSMAN. MGMT_IP_ELEM_PARAM_CLASSES (ELEMENT_TYPE_NLSID, ELEMENT_PARAM_CLASS, ELEMENT_NAME_NLSID, DISPLAY_ORDER) values ('target_user_table_from_sql', 'database_target_type', 'oracle.sysman.eml.ip.render.elem.SQLStatementParamController', 2);

    Commit;

    (2) checked the privileged references and surveillance powers. Password has been changed. Changed the same and report started running as expected.

  • DDL trigger

    Hello

    I tried DDL audit for help from under the sql statement,

    Audit on schema.tablename by access;

    This can be disabled by the No. AUDIT statement by the owner of the table.

    Please suggest me if DDL trigger can be used, if so, please help me with the script to create the trigger so that the DDL statement issued by the owner of the table can be monitored and verified.


    I don't know exactly why you need, but here is an example of code to audit the DDL from a particular table

    ------------

    -Table to contain the audit entries

    create the table aud_log_btopg

    (

    VARCHAR2 (50) of the event.

    object_name varchar (1000).

    object_type varchar2 (50).

    action_date varchar2 (50).

    machine to varchar2 (50).

    program varchar2 (50).

    OSUSER varchar2 (50).

    dbuser varchar2 (50).

    sql_text varchar2 (1000)

    )

    /

    -Trigger to insert audit logging information in the table above

    create or replace trigger aud_ddl_btopg
    after create or alter or drop on &SCHEMA
    declare
      v_num NUMBER;
      sql_stmt varchar2(2000);
      sql_text ora_name_list_t;
      l_sysevent varchar2(50);
      l_obj_name varchar2(50);
      l_obj_type varchar2(50);
      l_machine varchar2(50);
      l_prog varchar2(50);
      l_osuser varchar2(50);
      l_username varchar2(50);
      l_date varchar2(100);
    begin
      -- if object of interest
      if ora_dict_obj_name = '&YOUR_TABLE' THEN
      -- get SQL executed
      v_num := ora_sql_txt(sql_text);
      FOR i in 1..NVL(v_num,0) LOOP
      sql_stmt:=sql_stmt||sql_text(i);
      END LOOP; 
      -- get the rest of the audit information
      select ora_sysevent,ora_dict_obj_name,ora_dict_obj_type,
      to_char(sysdate,'fm dd/Mon/yyyy HH:MI:SS AM'),
      machine,program,osuser,username into l_sysevent,l_obj_name,l_obj_type,l_date,l_machine,l_prog,l_osuser,l_username
      from v$session
      where audsid = sys_context( 'userenv', 'sessionid' ); 
      -- insert into audit table
      insert into aud_log_btopg values (l_sysevent,l_obj_name,l_obj_type,l_date,l_machine,l_prog,l_osuser,l_username,sql_stmt); 
      if ( sql%rowcount <> 1 )
      then
      raise_application_error
      ( -20001, 'Unable to id your session' );
      end if; 
      end if;
    end;
    /

    ----

    I would not recommend the use of this type of audit in the production databases. Do not try to reinvent the wheel and use that provides the database.

    Rgds,

    IonutC

  • query to find bad queries that are taking place

    I write a job that takes place each a work hour.the will execute the query, the query will select identifiers of bad queries sql which is need for queries that have long been and always in running currently.we will run this work every time some sort of query has bad queries that perform queries currently.the o/p will be inserted into a table.i query to choose bad queries that is currently running

    something like that? (Instead of setting long-term work I would simply sort by time)

    SELECT sql_id

    executions

    elapsed_time

    TO_CHAR (buffer_gets, '999G999G999G999G999') buffer_gets

    , "percent overall.

    TO_CHAR (buffer_ex, '999G999G999G999') buffer_ex

    TO_CHAR (rows_ex, '999G999G999G999') rows_ex

    TO_CHAR (buffer_gets_row, '999G999G999G999') buffer_gets_row

    sql_text

    FROM (SELECT sql_id

    executions

    elapsed_time

    sql_text

    buffer_gets

    , ROUND ((buffer_gets) ratio_to_report () * 100) '% overall.

    , buffer_gets / buffer_ex of executions

    , rows_processed / rows_ex of executions

    , buffer_gets / DECODE (rows_processed, 0, 1, NULL, 1, rows_processed) buffer_gets_row

    V $ sql

    WHERE executions > 0

    AND buffer_gets > 0

    Sql_id AND to (select sql_id in session $ v where status = 'ACTIVE'))

    WHERE the "Total %" > = 5

    OR buffer_ex > 1000

    OR buffer_gets_row > 8

    ORDER BY DESC elapsed_time;

    (I guess you can't use v$ sql_monitor, otherwise the answer.)

  • Extract all nodes and filter them based on the WHERE clause

    <?xml version="1.0" encoding="UTF-8"?>
    <report_repository_summary>
       <sql sql_id="gyn915ynqjspa" sql_exec_start="08/19/2015 22:23:02" sql_exec_id="16777217">
          <status>DONE</status>
          <sql_text>BEGIN DBMS_STATS.GATHER_FIXED_OBJECTS_STATS; END;</sql_text>
          <first_refresh_time>08/19/2015 22:23:10</first_refresh_time>
          <last_refresh_time>08/19/2015 22:24:52</last_refresh_time>
          <refresh_count>54</refresh_count>
          <inst_id>1</inst_id>
          <session_id>26</session_id>
          <session_serial>20363</session_serial>
          <user_id>0</user_id>
          <user>SYS</user>
          <con_id>3</con_id>
          <con_name>PDB01_1</con_name>
          <module>sqlplus@lab (TNS V1-V3)</module>
          <service>1_1.up.com</service>
          <program>sqlplus@lab (TNS V1-V3)</program>
          <plan_hash>0</plan_hash>
          <is_cross_instance>N</is_cross_instance>
          <stats type="monitor">
             <stat name="duration">110</stat>
             <stat name="elapsed_time">109822091</stat>
             <stat name="cpu_time">78295097</stat>
             <stat name="user_io_wait_time">1388002</stat>
             <stat name="application_wait_time">1228</stat>
             <stat name="concurrency_wait_time">9175702</stat>
             <stat name="cluster_wait_time">41691</stat>
             <stat name="plsql_exec_time">39369731</stat>
             <stat name="other_wait_time">20920371</stat>
             <stat name="buffer_gets">616087</stat>
             <stat name="read_reqs">837</stat>
             <stat name="read_bytes">22998016</stat>
          </stats>
       </sql>
    </report_repository_summary>
    
    
    

    With above document XML stored as varchar2 (4000) in 12.1.0.2.0, how can I retrieve and display the relevant information(sql_id,session_id,plan_hash,duration,read_bytes) based on the place where condition to filter on any node. For example.

    select * from (
    SELECT EXTRACT (xmltype.createxml (a.report_summary), '//stats/stat[2]/text()').getstringval () AS elap_time from dba_hist_reports a WHERE component_name = 'sqlmonitor'
    )
    where elap_time > 100000000
    /
    
    
    

    Here, I try to get sql_id, sql_exec_id, duration and other information stored in the xml document by applying the where on elapsed_time condition. But to do this, I must write the part EXTRACT for all nodes in the inline view which seems like very bad way of writing of XML query. Is there an easy way to get all the information of nodes so that I can freely apply node whatever, I want in the WHERE condition to filter the records? No better way to write the code then the code below?

    select     REPORT_ID,
               EXTRACT (xmltype(a.report_summary), '//sql/@sql_id')                                    "sql_id",
               EXTRACT (xmltype(a.report_summary), '//sql/@sql_exec_id')                               "sql_exec_id",
               EXTRACT (xmltype(a.report_summary), '//sql/@sql_id')                                    "sql_exec_start",
               EXTRACT (xmltype(a.report_summary), '//status/text()')                                  "status",
               EXTRACT (xmltype(a.report_summary), '//sql_text/text()')                                "sql_text",
               EXTRACT (xmltype(a.report_summary), '//first_refresh_time/text()')              "first_refresh_time",
               EXTRACT (xmltype(a.report_summary), '//last_refresh_time/text()')               "last_refresh_time",
               EXTRACT (xmltype(a.report_summary), '//refresh_count/text()')                   "refresh_count",
               EXTRACT (xmltype(a.report_summary), '//inst_id/text()')                                         "inst_id",
               EXTRACT (xmltype(a.report_summary), '//session_id/text()')                              "session_id",
               EXTRACT (xmltype(a.report_summary), '//session_serial/text()')                  "session_serial",
               EXTRACT (xmltype(a.report_summary), '//user_id/text()')                                         "user_id",
               EXTRACT (xmltype(a.report_summary), '//user/text()')                                    "user",
               EXTRACT (xmltype(a.report_summary), '//con_id/text()')                                  "con_id",
               EXTRACT (xmltype(a.report_summary), '//con_name/text()')                                "con_name",
               EXTRACT (xmltype(a.report_summary), '//module/text()')                                  "module",
               EXTRACT (xmltype(a.report_summary), '//service/text()')                                         "service",
               EXTRACT (xmltype(a.report_summary), '//program/text()')                                         "program",
               EXTRACT (xmltype(a.report_summary), '//plan_hash/text()')                               "plan_hash",
               EXTRACT (xmltype(a.report_summary), '//is_cross_instance/text()')               "is_cross_instance",
               EXTRACT (xmltype(a.report_summary), '//stat[1]/text()')                                 "duration",
               EXTRACT (xmltype(a.report_summary), '//stat[2]/text()')                                 "elapsed_time",
               EXTRACT (xmltype(a.report_summary), '//stat[3]/text()')                                 "cpu_time",
               EXTRACT (xmltype(a.report_summary), '//stat[4]/text()')                                 "user_io_wait_time",
               EXTRACT (xmltype(a.report_summary), '//stat[5]/text()')                                 "application_wait_time",
               EXTRACT (xmltype(a.report_summary), '//stat[6]/text()')                                 "concurrency_wait_time",
               EXTRACT (xmltype(a.report_summary), '//stat[7]/text()')                                 "cluster_wait_time",
               EXTRACT (xmltype(a.report_summary), '//stat[8]/text()')                                 "plsql_exec_time",
               EXTRACT (xmltype(a.report_summary), '//stat[9]/text()')                                 "other_wait_time",
               EXTRACT (xmltype(a.report_summary), '//stat[10]/text()')                                        "buffer_gets",
               EXTRACT (xmltype(a.report_summary), '//stat[11]/text()')                                        "read_reqs",
               EXTRACT (xmltype(a.report_summary), '//stat[12]/text()')                                        "read_bytes"
    from       DBA_HIST_REPORTS a
    

    Don't know why, but it pays just 1 or 0. Even in your case his statement just 0 or 1 for all X 2 columns table.

    I guess I do something wrong in declaring XPATH for X 2 table but not able to find what it is.

    It makes account 0 or 1 because path expressions are bad.

    "For example: ' @name ="duration"

    This is a Boolean expression, not a step of XPath and so gets evaluated as such, which gives 0/1 for false/true values.

    What you need, it is something like this:

    SELECT x1.*
    FROM dba_hist_reports t
       , xmltable('/report_repository_summary/sql'
           PASSING xmlparse(document t.report_summary)
           COLUMNS
             sql_id              varchar2(15) path '@sql_id'
           , sql_exec_start      varchar2(30) path '@sql_exec_start'
           , sql_exec_id         number       path '@sql_exec_id'
           , status              varchar2(10) path 'status'
           , stats_duration      number       path 'stats/stat[@name="duration"]'
           , stats_elapsed_time  number       path 'stats/stat[@name="elapsed_time"]'
           , stats_cpu_time      number       path 'stats/stat[@name="cpu_time"]'
         ) x1
    where sql_id = 'c1tb2666n5rfx'
    and sql_exec_id = 16777668
    

Maybe you are looking for

  • use of the iPhone's cellular data

    New iPhone for 10 days; discovered that I used almost half my monthly data plan. But in the verification of the system services to see what to use, 751 on 777 MB used are grouped into 'general '. What is general? Passed Galaxy, where I did use essent

  • You can erase the songs on your iPod shuffle and repeat?

    How do clear you the air out of an iPod Shuffle?

  • Why browsers plant them

    Hello community, Recently, I saved an old Macbook 5.1 (13 in 2008) of a parent. The laptop has been abused, dropped enough solidarity to fold the chassis; DVD Player cannot be used or installed replacement. But with the damage he still roared to life

  • Webcam Chicony USB 2.0 on Satellite A215-S7444 - problem solved

    This is my system summary:Name of the operating system Microsoft Windows Vista Home PremiumVersion 6.0.6000 Build 6000Satellite A215 system modelSystem Type X 86-based PCProcessor AMD Turion (TM) 64 X 2 2 logical processors, 2 Lossnay, 1900 Mhz, tech

  • Go all on my new Dell.

    Hi people, I have an old HP Pavilion and would spend most of what's on it to my new Dell Studio Slim Desttop can anyone give me some advice on the best way to go about this please. Parkwood40