What is the correct procedure of DMBS_XPLAN for the query execution plan

Hello.

We are on Oracle 11.2.0.3 on Linux. I am dev. DBA and we have about 80 developers Java development team. They want to question the execution plan of queries to resolve the sqls. Generally, they use the GUI tools like the toad to see execution plan. I always use the procedure for the following query execution plan:


Select * from
Table (dbms_xplan.display_cursor (null, null, 'allstats + cost'));

I should suggest that they use this too rather than rely on tools like the toad - because they can show estimated plan and not the actual plan. And to provide a sql, it is best to use the real plan to work with. Do not take account of 'allstats + cost' part in the command above, but my point is: should I ask them of still rely on sqlplus and not the GUI tools and use the command display_cursor package DBMS_XPLAN?

I will be grateful for suggestions.

OrauserN

You must use the DBMS_XPLAN package and functionality.

The tool used to run the package doesn't matter. A raw request to DISPLAY_CURSOR will run the same server code in any tool including Toad.

If you rely on other GUI features (for example a "explain plan" button or similar) then you know what this feature of actuall application running under-the-covers.

My suggestion would be to assess and consider using Oracle free sql developer version 4 because it is not only FREE but also uses the DBMS_XPLAN correctly.

http://www.Oracle.com/technetwork/developer-tools/SQL-Developer/downloads/index.html?ssSourceSiteId=ocomen

Tags: Database

Similar Questions

  • What is the query to find the name of all applications for all EBS R12.1.3 modules?

    What is the query to find the name of all applications for all EBS R12.1.3 modules?

    With regard to:

    Mr. Shahzad Saleem

    Try:

    SELECT * FROM fnd_concurrent_programs_vl;

  • How to understand the implementation of the plan in oracle I mean if I see two implementation plans for a single sql_id plans 2 How to determine the best execution plan? Links and answers are much appreciated. Thank you

    How to understand the implementation of the plan in oracle I mean if I see two implementation plans for a single sql_id plans 2 How to determine the best execution plan? Links and answers are much appreciated. Thank you

    How to understand the implementation of the plan in oracle I mean if I see two implementation plans for a single sql_id plans 2 How to determine the best execution plan? Links and answers are much appreciated. Thank you

    After two execution plans that have the same sql_id, so we can see what you're talking about.

    See "Oracle Explain Explain Plan optimizer" by Maria Colgan of the Oracle optimizer group

    http://www.Oracle.com/technetwork/database/bi-Datawarehousing/TWP-explain-the-explain-plan-052011-393674.PDF

    Examine the various aspects of a selectivity to parallel execution plan

    performance and understand what information you should be brilliant

    the plan can be overwhelming even for the most experienced DBA. This document

    offers a detailed explanation on each of the aspects of the execution plan and a

    Overview of what caused the CBO to make the decision, he did.

  • How to get the query execution time without running...?

    Hello

    I had one condition... as follows...
    I had 3 sql statements. I need to run only sql what runtime is very less.

    Can someone help me, how to get the time query and run this query without using explain plan... ?

    Thank you
    Rajesh

    I can't think in any way at all to get the query execution time without running the query.

    You might get an estimate ( approximation ) If you are using explain plan.

    But you have governed to explain plan for a reason, so I can't help you.
    Why you do not want to use don't explain plan?

  • Need help to get the actual execution plan

    I need to get the actual execution plan of a query and its actual cost.
    If I understand correctly explaining the plan gives only the estimated according to my plan. Can someone help me please?

    I'm doing this:

    SQL> select OBJECT_NAME,DATA_OBJECT_ID,STATUS from dba_objects where owner='SANTU';
    
    OBJECT_NAME
                                                     DATA_OBJECT_ID STATUS
    --------------------------------------------------------------------------------
    ------------------------------------------------ -------------- -------
    TST_REDEF
                                                              73444 VALID
    REDEF_PK
                                                              73447 VALID
    
    SQL> select sql_id,sql_text from v$sqlarea where sql_text like '%DATA_OBJECT_ID,STATUS from dba_objects%';
    
    SQL_ID
    -------------
    SQL_TEXT
    --------------------------------------------------------------------------------
    gbvnfhs59t98f
    select sql_id,sql_text from v$sqlarea where sql_text like '%DATA_OBJECT_ID,STATUS from dba_objects%'
    
    bxdyf6ph2g3ay
    select OBJECT_NAME,DATA_OBJECT_ID,STATUS from dba_objects where owner='SANTU'
    
    SQL> select * from table(dbms_xplan.display_cursor('bxdyf6ph2g3ay'));
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    SQL_ID  bxdyf6ph2g3ay, child number 0
    -------------------------------------
    select OBJECT_NAME,DATA_OBJECT_ID,STATUS from dba_objects where
    owner='SANTU'
    
    Plan hash value: 2160718650
    
    ------------------------------------------------------------------------------------------------
    | Id  | Operation                        | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
    ------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                 |             |       |       |    47 (100)|          |
    |   1 |  VIEW                            | DBA_OBJECTS |  1638 |   161K|    47 (3)| 00:00:01 |
    |   2 |   UNION-ALL                      |             |       |       |    |          |
    |*  3 |    FILTER                        |             |       |       |    |          |
    |*  4 |     HASH JOIN                    |             |  1830 |   209K|    46 (3)| 00:00:01 |
    |   5 |      INDEX FULL SCAN             | I_USER2     |    88 |  1936 |     1 (0)| 00:00:01 |
    |   6 |      NESTED LOOPS                |             |  1830 |   169K|    45 (3)| 00:00:01 |
    |   7 |       TABLE ACCESS BY INDEX ROWID| USER$       |     1 |    18 |     1 (0)| 00:00:01 |
    |*  8 |        INDEX UNIQUE SCAN         | I_USER1     |     1 |       |     0 (0)|          |
    |*  9 |       TABLE ACCESS FULL          | OBJ$        |  1830 |   137K|    44 (3)| 00:00:01 |
    |* 10 |     TABLE ACCESS BY INDEX ROWID  | IND$        |     1 |     8 |     2 (0)| 00:00:01 |
    |* 11 |      INDEX UNIQUE SCAN           | I_IND1      |     1 |       |     1 (0)| 00:00:01 |
    |  12 |     NESTED LOOPS                 |             |     1 |    29 |     2 (0)| 00:00:01 |
    |* 13 |      INDEX FULL SCAN             | I_USER2     |     1 |    20 |     1 (0)| 00:00:01 |
    |* 14 |      INDEX RANGE SCAN            | I_OBJ4      |     1 |     9 |     1 (0)| 00:00:01 |
    |  15 |    NESTED LOOPS                  |             |     1 |    97 |     1 (0)| 00:00:01 |
    |  16 |     TABLE ACCESS BY INDEX ROWID  | USER$       |     1 |    18 |     1 (0)| 00:00:01 |
    |* 17 |      INDEX UNIQUE SCAN           | I_USER1     |     1 |       |     0 (0)|          |
    |* 18 |     INDEX RANGE SCAN             | I_LINK1     |     1 |    79 |     0 (0)|          |
    ------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter(((("O"."TYPE#"<>1 AND "O"."TYPE#"<>10) OR ("O"."TYPE#"=1 AND =1))
    AND
                  (("O"."TYPE#"<>4 AND "O"."TYPE#"<>5 AND "O"."TYPE#"<>7 AND "O"."TYPE#"<>8 AND
                  "O"."TYPE#"<>9 AND "O"."TYPE#"<>10 AND "O"."TYPE#"<>11 AND "O"."TYPE#"<>12 AND
                  "O"."TYPE#"<>13 AND "O"."TYPE#"<>14 AND "O"."TYPE#"<>22 AND "O"."TYPE#"<>87 AND
                  "O"."TYPE#"<>88) OR BITAND("U"."SPARE1",16)=0 OR (INTERNAL_FUNCTION("O"."TYPE#") AND
                  ((SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE' AND "U"."TYPE#"<>2) OR
                  ("U"."TYPE#"=2 AND "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')))
                  OR  IS NOT NULL)))))
       4 - access("O"."OWNER#"="U"."USER#")
       8 - access("U"."NAME"='SANTU')
       9 - filter(("O"."NAME"<>'_NEXT_OBJECT' AND "O"."NAME"<>'_default_auditing_opt
    ions_'
                  AND "O"."LINKNAME" IS NULL AND BITAND("O"."FLAGS",128)=0 AND "O"."
    SPARE3"="U"."USER#"))
      10 - filter(("I"."TYPE#"=1 OR "I"."TYPE#"=2 OR "I"."TYPE#"=3 OR "I"."TYPE#"=4
    OR
                  "I"."TYPE#"=6 OR "I"."TYPE#"=7 OR "I"."TYPE#"=9))
      11 - access("I"."OBJ#"=:B1)
      13 - access("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','
    current_
                  edition_id')))
           filter(("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv',
    'current
                  _edition_id'))))
      14 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88 AND "O2"."OWNER#"="U2"."US
    ER#")
      17 - access("U"."NAME"='SANTU')
      18 - access("L"."OWNER#"="U"."USER#")
    
    57 rows selected.
    
    SQL>
    

    Execution plans

    Kind regards
    S.K.

  • What are the Business Catalyst Plans to treat the NPAPI issues?

    BC currently using NPAPI plug ins Google Chrome throws up an error message when Chrome users visiting a site BC. Visitors are complaining.  What are the plans at this address?

    (UPDATED) Tier 2 Support SC confirmed that the platform of the BC introduces OBJECTS NPAPI. If some appear in the HTML code, they can be removed without problem.

    Current belief is that NPAPI objects are / were inserted by a Norton Symantic application running on the computer editing.

    I can confirm that remove the NPAPI object code clears the problem and does not otherwise affect the operation of the Web site.

  • What is the query block?

    Hi guys,.

    I searched a lot on the "query block" on google, but dosent find any satisfactory article that will explain basic concept to me.

    I would like to know about the parameter query block that we specified when using indicators of query optimization in oracle.


    How can they be used? where we can find them?


    any suggestions?


    Thanks and greetings
    VD

    Vkrant,
    You did exactly the same thing that is asked of me all the time. What is the purpose of this indication in a simple query that I have to show you all the time. The answer is nothing, makes complex things however. But but but, in a very complex query, where there is a cross reference of the sections of different query is required, this trick will be useful to give a name to the underlying query.
    >
    Select / * + dept_id full (@qb d) QB_NAME (qb)
    of db.dept d;

    can we say its just alias?
    >
    Yes, any. Give an official name to the query. In this query, Department table will be available with FTS.
    HTH
    Aman...

  • the two execution Plan

    Hello
    can you be kind to such me which is better and why (based on the columns of the execution Plan):
    Execution Plan A
    ----------------------------------------------------------
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=17)
       1    0   SORT (AGGREGATE)
       2    1     INDEX (RANGE SCAN) OF 'TEST_IDX' (NON-UNIQUE) (Cost=2 Card=1 Bytes=17)
       3    2       SORT (AGGREGATE)
       4    3         FIRST ROW (Cost=2 Card=6 Bytes=60)
       5    4           INDEX (RANGE SCAN (MIN/MAX)) OF 'TEST_IDX' (NON-UNIQUE) (Cost=2 Card=1060)
    
    tkprof gek1_ora_16520.trc gek1_ora_16520.out explain=scott/tiger sort=exeela sys=no
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          2          0           0
    Fetch        2      0.00       0.00          0          2          0           1
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        4      0.00       0.00          0          4          0           1 
    AND:
    Execution Plan B
    ----------------------------------------------------------
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=13)
       1    0   COUNT (STOPKEY)
       2    1     VIEW (Cost=2 Card=6 Bytes=78)
       3    2       INDEX (RANGE SCAN DESCENDING) OF 'TEST_IDX' (NON-UNIQUE) (Cost=2 Card=6 Bytes=102) 
    
    tkprof gek1_ora_16521.trc gek1_ora_16521.out explain=scott/tiger sort=exeela sys=no
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.03       0.06          2         41          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        2      0.00       0.00          0          2          0           1
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        4      0.03       0.06          2         43          0           1 
    Thank you.

    What is the version of db? Why you have not posted the actual queries as well? In a very generic view, the first is more beautiful, but is purely based on the elapsed time. What you are actually looking for?

    HTH
    Aman...

  • Get the SQL execution plan that is currently running in 9i

    Hello

    Apologies for the magnitude of this issue, but I was wondering if someone could help me to the more accurate/efficient way to get a piece of running Oracle 9i SQL execution plan.

    in 10g and 11g of course dbms_xplan.display_cursor (sql_id) can be used.

    How can this be achieved in 9i, currently I am just get the SQL_TEXT and then executing a plan to explain ("EXPLAIN PLAN for.") - I think that this is not neccesserally the same plan to explain that will be used for the sql code that runs if

    Any help would be appreciated.

    Thank you

    The plan exists after analysis difficult.
    Statistics of actual execution will require a completed.
    That is why sql followed in real time is so great in 11g.
    In 9i, difficult.

  • CBO does not choose the right execution plan

    Database: Oracle 9.2.0.6 EA
    OS: Solaris 9

    I'm trying to settle a query that is generated through Siebel Analytics. I see a behavior which is confusing to me but I hope, would be 'basic' for someone like JPL.

    The query is based on a total of 7 tables. If I comment on the 2 dimension tables, the query takes the right index finger on the fact table. However, at the point where I have to add another table to the query, the plan goes awry.

    The query with 5 tables is as below:
    select count(distinct decode( T30256.HEADER_FLG , 'N' , T30256.ROW_WID ) ) as c1,
    T352305.DAY_DT as c2,
    case  when T44643.PRODUCT_CLASS_NAME = 'MobileSubscription' then T40081.ATTR15_CHAR_VAL else 'Unspecified' end  as c3,
    T352305.ROW_WID as c5
    from 
                   W_PRODUCT_D T30955,
                   W_PRDATTRNM_D T44643,                          
                   W_DAY_D T352305,                  
                   W_ORDERITEM_F T30256,               
                   W_PRDATTR_D T40081                          
    where  ( T30955.ROW_WID = T44643.ROW_WID 
    and T30256.LAST_UPD_DT_WID = T352305.ROW_WID 
    and T30256.PROD_ATTRIB_WID = T40081.ROW_WID  
    and T30256.PROD_WID = T30955.ROW_WID 
    and T30955.PROD_NAME = 'Mobile Subscription' 
    and (case  when T44643.PRODUCT_CLASS_NAME = 'MobileSubscription' then T40081.ATTR15_CHAR_VAL else 'Unspecified' end  in ('BT150BB-18M', 'BT250BB-18M', 'BT50BB-18M', 'BT600BB-18M')) 
    and T352305.DAY_DT between TO_DATE('2008-09-27' , 'YYYY-MM-DD') - 7 and TO_DATE('2008-09-27' , 'YYYY-MM-DD') - 1 
    ) 
    group by 
    T352305.ROW_WID, T352305.DAY_DT, 
    case  when T44643.PRODUCT_CLASS_NAME = 'MobileSubscription' then T40081.ATTR15_CHAR_VAL else 'Unspecified' end 
    ;
    And the implementation plan is as below:
    ----------------------------------------------------------------------------------------------
    | Id  | Operation                        |  Name                | Rows  | Bytes | Cost (%CPU)|
    ----------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                 |                      |   269 | 25824 | 18660   (3)|
    |   1 |  SORT GROUP BY                   |                      |   269 | 25824 | 18660   (3)|
    |   2 |   NESTED LOOPS                   |                      |   269 | 25824 | 18658   (3)|
    |   3 |    NESTED LOOPS                  |                      |  6826 |   579K|  4734   (3)|
    |   4 |     MERGE JOIN CARTESIAN         |                      |     8 |   544 |     6  (17)|
    |   5 |      NESTED LOOPS                |                      |     1 |    54 |     4  (25)|
    |   6 |       TABLE ACCESS BY INDEX ROWID| W_PRODUCT_D          |     1 |    37 |     3  (34)|
    |*  7 |        INDEX RANGE SCAN          | W_PRODUCT_D_M2       |     1 |       |     2  (50)|
    |   8 |       TABLE ACCESS BY INDEX ROWID| W_PRDATTRNM_D        |     1 |    17 |     2  (50)|
    |*  9 |        INDEX UNIQUE SCAN         | W_PRDATTRNM_D_P1     |     1 |       |            |
    |  10 |      BUFFER SORT                 |                      |     8 |   112 |     4   (0)|
    |  11 |       TABLE ACCESS BY INDEX ROWID| W_DAY_D              |     8 |   112 |     3  (34)|
    |* 12 |        INDEX RANGE SCAN          | W_DAY_D_M39          |     8 |       |     2  (50)|
    |  13 |     TABLE ACCESS BY INDEX ROWID  | W_ORDERITEM_F        |   849 | 16131 |   592   (3)|
    |* 14 |      INDEX RANGE SCAN            | W_ORDERITEM_F_INDX9  |   852 |       |     4  (25)|
    |* 15 |    INDEX RANGE SCAN              | W_PRDATTR_D_M29_T1   |     1 |     9 |     3  (34)|
    ----------------------------------------------------------------------------------------------
    Note how the dimension tables W_PRODUCT_D & W_DAY_D are connected by a Cartesian join before joining the fact W_ORDERITEM_F table using the composite index 'W_ORDERITEM_F_INDX9 '. This index is composed of LAST_UPD_DT_WID, PROD_WID and ACTION_TYPE_WID, which are foreign keys to the dimension tables.

    Now, if I add several tables to the query:
    select count(distinct decode( T30256.HEADER_FLG , 'N' , T30256.ROW_WID ) ) as c1,
                  T352305.DAY_DT as c2,
                   case  when T44643.PRODUCT_CLASS_NAME = 'MobileSubscription' then T40081.ATTR15_CHAR_VAL else 'Unspecified' end  as c3,
                   T30371.X_BT_DLR_GROUP as c4,
                   T352305.ROW_WID as c5
              from                W_PRODUCT_D T30955,
                   W_PRDATTRNM_D T44643,                          
                   W_DAY_D T352305,                  
                   W_ORDERITEM_F T30256,               
                   W_ORDER_D T30371,                                             
                   W_PRDATTR_D T40081                          
              where  ( T30955.ROW_WID = T44643.ROW_WID 
              and T30256.LAST_UPD_DT_WID = T352305.ROW_WID 
              and T30256.PROD_ATTRIB_WID = T40081.ROW_WID 
              and T30256.PROD_WID = T30955.ROW_WID 
              and T30256.ORDER_WID = T30371.ROW_WID 
              and T30955.PROD_NAME = 'Mobile Subscription' 
              and T30371.STATUS_CD = 'Complete' 
              and T30371.ORDER_TYPE = 'Sales Order'  
              and (case  when T44643.PRODUCT_CLASS_NAME = 'MobileSubscription' then T40081.ATTR15_CHAR_VAL else 'Unspecified' end  in ('BT150BB-18M', 'BT250BB-18M', 'BT50BB-18M', 'BT600BB-18M')) 
              and T352305.DAY_DT between TO_DATE('2008-09-27' , 'YYYY-MM-DD') - 7 and TO_DATE('2008-09-27' , 'YYYY-MM-DD') - 1 
             ) 
              group by T30371.X_BT_DLR_GROUP, T352305.ROW_WID, T352305.DAY_DT, 
              case  when T44643.PRODUCT_CLASS_NAME = 'MobileSubscription' then T40081.ATTR15_CHAR_VAL else 'Unspecified' end;
    I added a single table W_ORDER_D to the query and execution plan is:
    -----------------------------------------------------------------------------------------------
    | Id  | Operation                          |  Name               | Rows  | Bytes | Cost (%CPU)|
    -----------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                   |                     |    44 |  6336 | 78695   (3)|
    |   1 |  SORT GROUP BY                     |                     |    44 |  6336 | 78695   (3)|
    |   2 |   NESTED LOOPS                     |                     |    44 |  6336 | 78694   (3)|
    |   3 |    NESTED LOOPS                    |                     |   269 | 27707 | 78145   (3)|
    |*  4 |     HASH JOIN                      |                     |  6826 |   626K| 64221   (3)|
    |   5 |      TABLE ACCESS BY INDEX ROWID   | W_DAY_D             |     8 |   112 |     4  (25)|
    |*  6 |       INDEX RANGE SCAN             | W_DAY_D_M39         |     1 |       |     3  (34)|
    |   7 |      TABLE ACCESS BY INDEX ROWID   | W_ORDERITEM_F       | 86886 |  2206K| 64197   (3)|
    |   8 |       NESTED LOOPS                 |                     | 87004 |  6797K| 64200   (3)|
    |   9 |        NESTED LOOPS                |                     |     1 |    54 |     4  (25)|
    |  10 |         TABLE ACCESS BY INDEX ROWID| W_PRODUCT_D         |     1 |    37 |     3  (34)|
    |* 11 |          INDEX RANGE SCAN          | W_PRODUCT_D_M2      |     1 |       |     2  (50)|
    |  12 |         TABLE ACCESS BY INDEX ROWID| W_PRDATTRNM_D       |     1 |    17 |     2  (50)|
    |* 13 |          INDEX UNIQUE SCAN         | W_PRDATTRNM_D_P1    |     1 |       |            |
    |* 14 |        INDEX RANGE SCAN            | W_ORDERITEM_F_N6    | 86886 |       |   212  (18)|
    |* 15 |     INDEX RANGE SCAN               | W_PRDATTR_D_M29_T1  |     1 |     9 |     3  (34)|
    |* 16 |    INDEX RANGE SCAN                | W_ORDER_D_N6        |     1 |    41 |     3  (34)|
    -----------------------------------------------------------------------------------------------
    Now, CBO choose the composite index and the cost has also increased to 78695. But if I just add a / * + SORTED * / referring to the above query, whereas it should join the dimension tables prior to joining the fact table, then the cost falls to 20913. This means that CBO is not choose the plan with the lowest cost. I tried increasing the optimizer_max_permutations 80000, setting session optimizer_dynamic_sampling level 8 (just to see if it works), but without success.

    Could you please tell how to overcome this problem?

    Thank you very much.

    joshic wrote:
    Hi Randolph,

    The optimizer is set to 'choose', which is the default in 9i. So I guess that CBO uses the "all_rows" mode, because his stats are present.

    According to your advice, I tried to adjust optimizer_mode, first_rows_1, first_rows_10, first_rows_100 and all_rows at the session level, but nothing helped.

    Another question: since you are obviously having a schema star why don't you use not three separate bitmap indexes on the foreign key columns in the fact table? In this way, you can use a transformation star rather than using a composite index.

    You use many OLTP, small, such as transactions that modify your fact table, or is it only loaded by loading in bulk? If you use only loads in bulk index bitmap should be fine.

    Kind regards
    Randolf

    Oracle related blog stuff:
    http://Oracle-Randolf.blogspot.com/

    SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676 /.
    http://sourceforge.NET/projects/SQLT-pp/

  • What are the options in plan for my team of 2 or 3 people?

    I'm trying to decide if I should buy a plan with Adobe Stock or Shutterstock and want to know the application costs and number of download options plan I can't compare.

    Thank you! @AdobeCare

    Hello

    Details of the plans available here - Adobe Stock price and membership plan. Adobe Stock

    Thank you

    Bev

  • Should I wait until the end of the execution time of the query for the execution plan?

    Hello Experts,

    I want to see the execution plan of the query below. However, it takes more than 3 hours. Should I wait all the time to see the execution plan?

    Note: EXPLAIN PLAN for does not work. (I mean that I do not see the actual line number, etc. with EXPLAIN the PLAN of market)

    You can see the output of the execution plan when I canceled the execution after 1 minute.

    My first question is: what should I do to see the execution plan for queries running out of time time?

    2nd question: when I cancel the query during execution in order to see the execution plan, will I see the specific plan of execution or erroneous values? Because the first execution plan seems inaccurate, what do you think?

    question 3: why EXPLAIN the PLAN for the clause does not work? Also, should I use EXPLAIN the PLAN of the clause to this scenerio? Can I see the result of running for long time without her queries?

    Thnaks for your help.

    Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production

    PL/SQL Release 11.2.0.2.0 - Production

    CORE Production 11.2.0.2.0

    AMT for Linux: Version 11.2.0.2.0 - Production

    NLSRTL Version 11.2.0.2.0 - Production

    Select / * + GATHER_PLAN_STATISTICS NO_PARALLEL * / J.INVOICEACCOUNT, J.INVOICEID, J.INVOICEDATE, (T.LINEAMOUNT + T.LINEAMOUNTTAX) price

    of custinvoicejour j join custinvoicetrans t on

    substr (nls_lower (j.DataAreaId), 1, 7) = substr (nls_lower (t.dataareaid), 1, 7) and

    substr (nls_lower (J.INVOICEID), 1: 25) = substr (nls_lower (t.INVOICEID), 1: 25)

    where

    substr (nls_lower (T.DATAAREAID), 1, 7) = '201' and T.AVBROCHURELINENUM = 29457

    and substr (nls_lower (j.dataareaid), 1, 7) = '201' and

    J.INVOICEACCOUNT in

    (select IT. Drmpos.avtr_seg_cust_campend ACCOUNTNUM this where THIS. CAMPAIGN = '201406' and THIS. SEGMENT_LEVEL in (', 'E'))

    and J.AVAWARDSALES > 190

    and substr (nls_lower (J.AVBILLINGCAMPAIGN), 1, 13) = '201406'

    "and J.INVOICEDATE between ' 04.06.2014' and ' 13.06.2014 ';

    SQL_ID, dznya6x7st0t8, number of children 0

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

    Select / * + GATHER_PLAN_STATISTICS NO_PARALLEL * / J.INVOICEACCOUNT,.

    J.INVOICEID, J.INVOICEDATE, (T.LINEAMOUNT + T.LINEAMOUNTTAX) price of

    CustInvoiceJour j join custinvoicetrans t on

    substr (nls_lower (j.DataAreaId), 1, 7) =

    substr (nls_lower (t.DataAreaId), 1, 7) and

    = substr (nls_lower (J.INVOICEID), 1: 25)

    substr (nls_lower (t.INVOICEID), 1: 25) where

    substr (nls_lower (T.DATAAREAID), 1, 7) = '201' and T.AVBROCHURELINENUM =

    29457 and substr (nls_lower, (j.dataareaid), 1, 7) = '201' and

    J.INVOICEACCOUNT in (select CE. ACCOUNTNUM of

    drmpos.avtr_seg_cust_campend this where THIS. CAMPAIGN = '201406' and

    IT. SEGMENT_LEVEL in (', 'E')) and J.AVAWARDSALES > 190 and

    substr (nls_lower (J.AVBILLINGCAMPAIGN), 1, 13) = '201406' and

    "J.INVOICEDATE between ' 04.06.2014' and ' 13.06.2014 '.

    Hash value of plan: 2002317666

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

    | ID | Operation | Name                           | Begins | E - lines. A - lines.   A - time | Pads | Bed |  OMem |  1Mem | Used Mem.

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

    |   0 | SELECT STATEMENT |                                |      1.        |      0 | 00:00:00.01 |       0 |      0 |       |       |          |

    |*  1 |  HASH JOIN |                                |      1.   3956.      0 | 00:00:00.01 |       0 |      0 |  2254K |  1061K | 2190K (0) |

    |*  2 |   HASH JOIN |                                |      1.     87.  16676. 00:00:01.64 |     227K |   3552.  3109K |  1106K | 4111K (0) |

    |*  3 |    TABLE ACCESS BY INDEX ROWID | CUSTINVOICEJOUR |      1.   1155 |  31889 | 00:00:01.16 |     223KO |     15.       |       |          |

    |*  4 |     INDEX RANGE SCAN | I_062INVOICEDATEORDERTYPEIDX |      1.   4943 |    134K | 00:00:00.83 |   45440 |      0 |       |       |          |

    |   5.    SIMPLE LIST OF PARTITION.                                |      1.  82360 |    173K | 00:00:00.08 |    3809 |   3537 |       |       |          |

    |*  6 |     TABLE ACCESS FULL | AVTR_SEG_CUST_CAMPEND |      1.  82360 |    173K | 00:00:00.06 |    3809 |   3537 |       |       |          |

    |   7.   TABLE ACCESS BY INDEX ROWID | CUSTINVOICETRANS |      1.   4560 |      0 | 00:00:00.01 |       0 |      0 |       |       |          |

    |*  8 |    INDEX RANGE SCAN | I_064INVLINENUMCAMPAIGNOFPRICE |      1.   4560 |      0 | 00:00:00.01 |       0 |      0 |       |       |          |

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

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

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

    1 - access("J".") "SYS_NC00299$"="T". "' SYS_NC00165$ ' AND SUBSTR (NLS_LOWER ('J'. "" "" REFFACTURE")(, 1, 25) = SUBSTR (NLS_LOWER ("T"." "" "REFFACTURE")(, 1, 25)).

    2 - access("J".") INVOICEACCOUNT '= SYS_OP_C2C ("EC". ". ACCOUNTNUM'))

    3 - filter("J".") AVAWARDSALES"> 190)

    4 - access("J".") SYS_NC00299$ "= U ' 201"AND "J". INVOICEDATE"> = TO_DATE(' 2014-06-04 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND

    "J"." SYS_NC00307$ "= U ' 201406"AND "J". INVOICEDATE"< = TO_DATE (' 2014-06-13 00:00:00 ',' syyyy-mm-dd hh24:mi:ss')))

    filter ((' J'. "INVOICEDATE' > = 'J' AND TO_DATE(' 2014-06-04 00:00:00', 'syyyy-mm-dd hh24:mi:ss') '." " SYS_NC00307$ "= U '201406' AND"

    "J"." INVOICEDATE"< = TO_DATE (' 2014-06-13 00:00:00 ',' syyyy-mm-dd hh24:mi:ss'))))

    6 filter (("CE". "SEGMENT_LEVEL" = A "OR"THIS"." SEGMENT_LEVEL "=" E"))

    8 - access("T".") SYS_NC00165$ "= U ' 201"AND "T". AVBROCHURELINENUM "= 29457)

    filter ("T". ("AVBROCHURELINENUM" = 29457)

    EXPLAIN PLAN FOR

    Select / * + GATHER_PLAN_STATISTICS NO_PARALLEL * / J.INVOICEACCOUNT, J.INVOICEID, J.INVOICEDATE, (T.LINEAMOUNT + T.LINEAMOUNTTAX) price

    of custinvoicejour j join custinvoicetrans t on

    substr (nls_lower (j.DataAreaId), 1, 7) = substr (nls_lower (t.dataareaid), 1, 7) and

    substr (nls_lower (J.INVOICEID), 1: 25) = substr (nls_lower (t.INVOICEID), 1: 25)

    where

    substr (nls_lower (T.DATAAREAID), 1, 7) = '201' and T.AVBROCHURELINENUM = 29457

    and substr (nls_lower (j.dataareaid), 1, 7) = '201' and

    J.INVOICEACCOUNT in

    (select IT. Drmpos.avtr_seg_cust_campend ACCOUNTNUM this where THIS. CAMPAIGN = '201406' and THIS. SEGMENT_LEVEL in (', 'E'))

    and J.AVAWARDSALES > 190

    and substr (nls_lower (J.AVBILLINGCAMPAIGN), 1, 13) = '201406'

    "and J.INVOICEDATE between ' 04.06.2014' and ' 13.06.2014 ';

    SELECT * FROM table (DBMS_XPLAN. DISPLAY_CURSOR);

    SELECT * FROM table (DBMS_XPLAN. DISPLAY_CURSOR ('7h1nbzqjgwsp7', 2));

    SQL_ID, 7h1nbzqjgwsp7, number of children 2

    EXPLAIN PLAN for select / * + GATHER_PLAN_STATISTICS NO_PARALLEL * /.

    J.INVOICEACCOUNT, J.INVOICEID, J.INVOICEDATE,

    (T.LINEAMOUNT + T.LINEAMOUNTTAX) join price j custinvoicejour

    CustInvoiceTrans t on substr (nls_lower (j.dataareaid), 1, 7) =

    substr (nls_lower (t.DataAreaId), 1, 7) and

    = substr (nls_lower (J.INVOICEID), 1: 25)

    substr (nls_lower (t.INVOICEID), 1: 25) where

    substr (nls_lower (T.DATAAREAID), 1, 7) = '201' and T.AVBROCHURELINENUM =

    29457 and substr (nls_lower, (j.dataareaid), 1, 7) = '201' and

    J.INVOICEACCOUNT in (select CE. ACCOUNTNUM of

    drmpos.avtr_seg_cust_campend this where THIS. CAMPAIGN = '201406' and

    IT. SEGMENT_LEVEL in (', 'E')) and J.AVAWARDSALES > 190 and

    substr (nls_lower (J.AVBILLINGCAMPAIGN), 1, 13) = '201406' and

    "J.INVOICEDATE between ' 04.06.2014' and ' 13.06.2014 '.

    NOTE: cannot fetch SQL_ID plan: 7h1nbzqjgwsp7, CHILD_NUMBER: 2

    Check the value of SQL_ID and CHILD_NUMBER;

    It could also be that the plan is no longer in the cursor cache (check v$ sql_plan)

    NightWing wrote:

    Randolf,

    I don't understand. What you hear from the above statement that you mean A-lines and E will be incorrect, but the ratio between them remain the same. Therefore, you can deduct the bad things by comparing the differences.

    Thus, A-lines always give a wrong result for cancellation of queries, isn't it?

    Charlie,

    I think that Martin gave a good explanation. Here's another example that hopefully makes more obvious things:

    17:56:55 SQL >-things go very wrong here with a small buffer cache

    17:56:55 SQL >-T2 lines are badly scattered when you access through T1. FK

    17:56:55 SQL >--

    17:56:55 SQL >-"Small job" approach would have been a good idea

    17:56:55 SQL >-if the estimate of 100 iterations of the loop was correct!

    17:56:55 SQL > select

    17:56:55 (t2.attr2) count 2

    17:56:55 3 of

    17:56:55 4 t1

    17:56:55 5, t2

    17:56:55 6 where

    17:56:55   7  /*------------------*/

    17:56:55 8 trunc (t1.attr1) = 1

    17:56:55 9 and trunc (t1.attr2) = 1

    17:56:55 10 / *-* /.

    17:56:55 11 and t1.fk = t2.id

    17:56:55 12.

    T1

    *

    ERROR on line 4:

    ORA-01013: user has requested the cancellation of the current operation

    Elapsed time: 00:04:58.30

    18:01:53 SQL >

    18:01:53 SQL > @xplan_extended_display_cursor ' ' ' ' 'ALLSTATS LAST + COST.

    18:01:53 SQL > set echo off verify off termout off

    SQL_ID, 353msax56jvvp, number of children 0

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

    SELECT count (t2.attr2) from t1, t2 where

    / / *-* trunc (t1.attr1) = 1 and

    trunc (T1.attr2) = 1 / *-* / and t1.fk = t2.id

    Hash value of plan: 2900488714

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

    | ID | The NEST | DSB | Operation | Name | Begins | E - lines. Cost (% CPU). A - lines.   A - time | Pads | Bed |

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

    |   0 |     |   7. SELECT STATEMENT |        |      1.        |  4999 (100) |      0 | 00:00:00.01 |       0 |      0 |

    |   1.   0 |   8 2 GLOBAL TRI |        |      1.      1.            |      0 | 00:00:00.01 |       0 |      0 |

    |   2.   1.   5.   NESTED LOOPS |        |      1.        |            |  57516 | 00:04:58.26 |     173K |  30770 |

    |   3.   2.   3.    NESTED LOOPS |        |      1.    100.  4999 (1) |  57516 | 00:00:21.06 |     116K |   3632.

    |*  4 |   3.   1.     TABLE ACCESS FULL | T1 |      1.    100.  4799 (1) |  57516 | 00:00:00.19 |    1008 |   1087 |

    |*  5 |   3.   2.     INDEX UNIQUE SCAN | T2_IDX |  57516 |      1.     1 (0) |  57516 | 00:00:20.82 |     115K |   2545 |

    |   8 2 2 |   4.    TABLE ACCESS BY INDEX ROWID | T2 |  57516 |      1.     2 (0) |  57516 | 00:04:37.14 |   57516 |  27138 |

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

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

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

    4 filter ((TRUNC ('T1'. "ATTR1") = 1 AND TRUNC ('T1'. " ATTR2') = 1))

    5 - access("T1".") FK '= 'T2'.' (ID')

    You say here that I canceled a query after about 5 minutes, and looking at the statistics of content (RowSource) I can already say the following:

    1. the estimation of cardinality of T1 is far - the optimizer estimated 100 lines, but it actually generated more than 57000 lines when the query was cancelled. If this definitely seems like a candidate at the origin of the problems

    2. the query has spent most of the time in search of random table T2

    So while it is true that I don't know final A-lines of this cancelled query information, I can still say a lot of this and begin to deal with the problems identified so far.

    Randolf

  • How to capture the execution plan for a query

    Hi all

    Can someone help me please to find the command to capture the execution plan for a query.

    Execution plan for select * from EMP where < condition >

    Is getting executed successfully, but I need to get the appropriate for the same execution plan.

    Thank you

    Read the Doc

  • order of operations in the execution plan

    Hello

    I'm not sure if my order of the following execution plan is correct.

    So hopefully someone can confirm or refute my order of the plan.


    This is the query:

    SELECT DISTINCT 'A3. ' "' ISIN '.

    Of

    "WERTPAPIERE" "A3."

    "LOGTABLE" "A2."

    "WP_STATUS" "A1".

    WHERE

    "A2". "PK_ID"= "A3". "" IDENTITY CARD "AND

    "A2". "" REFERENCE "> TIMESTAMP' 2014-01-06 18:30 ' AND

    "A2". "" REFERENCE "< = TIMESTAMP' 2014-01-08 07:00 ' AND

    "A2". "" LOG_DATUM "> TIMESTAMP' 2014-01-07 18:30 ' AND

    "A2". "" LOG_DATUM "< = TIMESTAMP' 2014-01-08 07:00 ' AND

    "A2". "TABLE" = "WERTPAPIERE" AND "

    "A3". ' BATCH '= 'A1'. "" IDENTITY CARD "AND

    "A1". "" CODE "<>" * 33' AND "

    (THERE ARE

    (SELECT "BESTANDS_MERKM" 0 "A7"

    WHERE 'A7 '. "ID"= "A3". "' BESTANDS_MERKMAL_ID ' AND ('A7'. "CODE"= "1" OR "A7". "CODE"(= '2')) AND ("A3" ".") " USER name "= 'Ect' OR 'A3'." USER name "= 'pro' OR 'A3'". "" Username "(= 'prom') or does NOT EXIST"

    (SELECT 0

    OF 'BESTANDS_MERKM' "A6".

    WHERE "A6". «ID «= NVL ("A3".» ("' BESTANDS_MERKMAL_ID ', 0) AND ("A6". "CODE"= "1" OR "A6". "CODE"(= '2')) AND ("A3" ".") " Username "="Res"OR"A3"." Username "(= 'prom') AND ("A3"". ")" LOESCH_KZ_ID' IS NULL OR EXISTS

    (SELECT 0

    OF 'WERTPAPIER_LOESCH_KZ' "A5".

    WHERE "A5". "ID"= "A3". "' LOESCH_KZ_ID ' AND 'A5 '. (("CODE"="1")) AND THERE ARE

    (SELECT 'PRODUKTGRUPPE_SEGMENT' 0 'A4'

    WHERE "A4". "ID"= "A3". "' PRODUKTGRUPPE_SEGMENTIERUNG_ID ' AND ('A4'. "CODE"= "USE" OR "A4". "CODE"= "ZUUZ" OR "A4". "CODE"= "4000" OR "A4". "CODE"= "5000" OR "A4". "CODE"= "3000" OR "A4". "CODE"= "4444" OR "A4". "CODE"= "4445" OR "A4". "CODE"= "5544" OR "A4". "CODE"= "6544" OR "A4". «CODE ' = ' 6543 "OR"A4".» ((("CODE"="8765')))

    The plan has been acquired through dbms_xplan:

    Select * from table (dbms_xplan.display_cursor (format = > 'ALLSTATS LAST SCHEMA'));


    Here's the plan:


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

    | ID | Operation | Name                     | Begins | E - lines. A - lines.   A - time | Pads | Bed |  OMem |  1Mem | Used Mem.

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

    |   0 | SELECT STATEMENT |                          |      1.        |   1252 | 00:05:55.03 |      11 M |    594K |       |       |          |

    |   1.  UNIQUE HASH |                          |      1.  28517 |   1252 | 00:05:55.03 |      11 M |    594K |  1135K |  1135K | 2976K (0) |

    |*  2 |   FILTER                               |                          |      1.        |   2579 | 00:05:55.02 |      11 M |    594K |       |       |          |

    |*  3 |    HASH JOIN |                          |      1.    571K |   2219K | 00:05:53.49 |      11 M |    594K |  1306K |  1306K | 1 272 K (0) |

    |*  4 |     INDEX SCAN FULL | WP_STAT_UPI |      1.     57.     57. 00:00:00.01 |       1.      0 |       |       |          |

    |   5.     NESTED LOOPS |                          |      1.        |   2219K | 00:05:52.17 |      11 M |    594K |       |       |          |

    |   6.      NESTED LOOPS |                          |      1.    583K |   2219K | 00:00:18.62 |     726K |    436K |       |       |          |

    |   7.       RANGE OF SINGLE PARTITION |                          |      1.    583K |   2219K | 00:00:12.29 |     436K |    436K |       |       |          |

    |   8.        PARTITION LIST ALL |                          |      1.    583K |   2219K | 00:00:11.96 |     436K |    436K |       |       |          |

    |*  9 |         TABLE ACCESS FULL | LOGTABLE |      4.    583K |   2219K | 00:00:11.61 |     436K |    436K |       |       |          |

    | * 10 |       INDEX UNIQUE SCAN | WP_PK_I                  |   2219K |      1.   2219K | 00:00:05.34 |     289K |    491.       |       |          |

    |  11.      TABLE ACCESS BY INDEX ROWID | WERTPAPIERE |   2219K |      1.   2219K | 00:05:32.59 |      10 M |    157K |       |       |          |

    | * 12 |    TABLE ACCESS BY INDEX ROWID | BESTANDS_MERKM |      5.      1.      2. 00:00:00.01 |       8.      0 |       |       |          |

    | * 13 |     INDEX UNIQUE SCAN | BESTANDS_MERKM_PK_I |      5.      1.      4. 00:00:00.01 |       4.      0 |       |       |          |

    | * 14 |    TABLE ACCESS BY INDEX ROWID | BESTANDS_MERKM |      3.      1.      0 | 00:00:00.01 |       5.      0 |       |       |          |

    | * 15 |     INDEX UNIQUE SCAN | BESTANDS_MERKM_PK_I |      3.      1.      2. 00:00:00.01 |       3.      0 |       |       |          |

    | * 16.    TABLE ACCESS BY INDEX ROWID | PRODUKTGRUPPE_SEGMENT |      3.      1.      2. 00:00:00.01 |       6.      0 |       |       |          |

    | * 17.     INDEX UNIQUE SCAN | PRG_SEG_PK_I |      3.      1.      3. 00:00:00.01 |       3.      0 |       |       |          |

    | * 18.    INDEX UNIQUE SCAN | WERTPAPIER_LOESCH_KZ_UPI |      2.      1.      1. 00:00:00.01 |       2.      0 |       |       |          |

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

    Vector data

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

    /*+

    BEGIN_OUTLINE_DATA

    IGNORE_OPTIM_EMBEDDED_HINTS

    OPTIMIZER_FEATURES_ENABLE ('11.2.0.3')

    DB_VERSION ('11.2.0.3')

    ALL_ROWS

    OUTLINE_LEAF(@"SEL$2")

    OUTLINE_LEAF(@"SEL$3")

    OUTLINE_LEAF(@"SEL$4")

    OUTLINE_LEAF(@"BLOCK1")

    OUTLINE_LEAF(@"SEL$1")

    OUTLINE(@"BLOCK1")

    FULL (@"SALT$ 1" "A2"@"SEL$1")

    INDEX (@"SALT$ 1" "A3"@"SEL$1" ("WERTPAPIERE".) "ID")) "

    INDEX (@"SALT$ 1" "A1"@"SEL$1" ("WP_STATUS".) "CODE" "WP_STATUS" "." " ID'))

    LEADING (@"SALT$ 1" "A2"@"SEL$1" "A3"@"SEL$1" "A1"@"SEL$1")

    USE_NL (@"SALT$ 1" "A3"@"SEL$1")

    NLJ_BATCHING (@"SALT$ 1" "A3"@"SEL$1")

    USE_HASH (@"SALT$ 1" "A1"@"SEL$1")

    SWAP_JOIN_INPUTS (@"SALT$ 1" "A1"@"SEL$1")

    USE_HASH_AGGREGATION(@"SEL$1")

    INDEX_RS_ASC (@"BLOCK1" "A4"@"BLOCK1" ("PRODUKTGRUPPE_SEGMENT".) "ID")) "

    INDEX (@"SALT$ 4" "A5"@"SEL$4" ("WERTPAPIER_LOESCH_KZ".) "CODE" "WERTPAPIER_LOESCH_KZ" "." " ID'))

    INDEX_RS_ASC (@"SALT$ 3" "A6"@"SEL$3" ("BESTANDS_MERKM".) "ID")) "

    INDEX_RS_ASC (@"SALT$ 2" "A7"@"SEL$2" ("BESTANDS_MERKM".) "ID")) "

    END_OUTLINE_DATA

    */

    According to independent-combine- JOIN operation by HASH, I assumed the first operation's Id 4 because the "INDEX FULL SCAN' on 'WP_STAT_UPI' is the first child.

    So I guess the order of operations by Id is 4,9,10 and so on.

    I got my information from the official oracle documentation, the book of Troubleshooting Oracle Performance (APRESS) and some research on the internet.

    Unfortunately so far I have found a good documentation on the scheduling. Most of the tutorials and documentation talk a lot operations themselves, but very little about the opening sequence.

    According to the section ATTACK to State "LEADING(@"SEL$1""A2"@"SEL$1""A3"@"SEL$1""A1"@"SEL$1")", for the classification should be Id: 9,10 and so on.


    I also tried to find order information in the v$ sql_plan. The database version is 11.2.


    Any help welcome.


    Best regards

    Your interpretation is correct (even if you have obscured the lines 5-8, but they do not add significant value to what you're saying).

    The explanation of the difference between your interpretation and the indicator leading() is the indicator USE_HASH() is accompanied by a hint of swap_join_inputs(). Hash joins | Oracle scratchpad indicator tells you the order of join optimizer was examining, but the optimizer exchange the roles of man and hash tables when it comes to her 'now to join A1 (WP_STAT)' part of the analysis - and this is reflected in the implementation plan.

    Symbolically, the main indicator says

    You should join A2 and A3--> (A2, A3)

    Then you must join A1--> ((A2, A3), A1)

    But Exchange - join entries. (A1, (A2, A3))

    Concerning

    Jonathan Lewis

  • Please someone help me on the query.

    I'm using oracle 11g. The column has many numbers. few are positive numbers, negative numbers are few, and few are zero.

    the table structure is as this:

    Col1

    9

    -5

    3

    60

    10

    -15

    -45

    0

    87

    Now, I have to count the number of positive, negative and all number the number zero of the column and display three columns like this:

    Nega_value

    Posi_value

    Zero_value

    3

    5

    1

    What would the query?

    Select sum (case when col1< 0="" then="" 1="" end)="">

    sum (case when col1 > 0 then 1 end) posi_value,.

    sum (case when col1 = 0 then 1 end) zero_value

    from your_table

    John

Maybe you are looking for