Sql query is running fast in sqlplus but too slow in oracle why?

Hi,
I am executing one query in sqlplus . it gives output in two mins. when run that query in oracle it takes above 7hrs. why?
what is root cause of this problem?

SQLPLUS is a part of Oracle :) Do you mean SQL server
Edited by: Maran.Viswarayar on Apr 19, 2010 11:49 PM

Similar Messages

  • Executing PL-SQL Query before running a Report

    Hi Guys,
    Can i use a Run a Pl-Sql Query every time before executing a report. Like if i am opening a report then the pl-sql Query should run before it.
    Thanks
    Rondo.

    Try with Evaluate as one of the column's expression.. so that we can limit to specific report..
    or
    Use Connection Pool->Connection Pool Scripts tab->use 'Execute before query'
    Since we can set the repository variables using advanced tab.. the same variable we may validate using Connection pool scripts tab.
    This might be more dev work..
    Edited by: Srini VEERAVALLI on Dec 17, 2012 9:00 PM

  • SQL query can be executed through TOAD but not through Discoverer

    Hallo, everybody:
    Got another problem. A SQL query can be executed through TOAD, but when I want to execute it by a worksheet of Discoverer Plus, it always shows there is no data.
    PS: I copied this query from Discoverer Plus to TOAD, which means, this query is generated through the Discoverer. Does anybody know about how could it be?
    Thank you.
    Geng

    Hi,
    If you are able to get data in TOAD with the same user credential as that of Discoverer Plus then it will implies an issue with Discoverer.
    Else it is privilege issue , your TOAD user has select privilege to the base objects (tables/views etc) where as your Disoverer used does not.
    Compare the privileges granted to these 2 users and you can narrow done to the issue .
    Thanks,
    Sutirtha

  • Sql Query is running fine in one database but running from long in other

    Hi All,
    Please advice me on below:
    One query is running fine on 11gr2 database with having 2GB SGA and cost of the running query is 15, but the same query is running from long time in other database having same 2GB SGA.
    Below is teh Query:
    SELECT CDU.USER_NAME, DECODE(:B2 , 'QUEUE','begin
    dbms_aqadm.grant_queue_privilege(''ALL'','''||:B1
    ||''','''||CDU.USER_NAME||''',true); end;', 'grant '||DECODE(:B2 ,
    'TABLE','SELECT,INSERT,UPDATE,DELETE'||DECODE(CDU.ADMIN,'Y',',REFERENCES
    ',''), 'VIEW',DECODE(:B3 ,NULL,'SELECT','SELECT,INSERT,UPDATE,DELETE'||D
    ECODE(CDU.ADMIN,'Y',',REFERENCES','')), 'TYPE','EXECUTE',
    'SEQUENCE','SELECT', 'EXECUTE')||' on
    '||PACK_UTILS.GET_SCHEMA_OWNER||'.'||:B1 ||' to
    "'||CDU.USER_NAME||'"'||DECODE(CDU.ADMIN,'Y',' WITH GRANT OPTION',''))
    AS GRANT_SOURCE, 'create or replace synonym
    "'||CDU.USER_NAME||'"."'||:B1 ||'" for
    "'||PACK_UTILS.GET_SCHEMA_OWNER||'"."'||:B1 ||'"' AS SYNONYM_SOURCE,
    NVL2( S.TABLE_NAME, 'Y', 'N' ) SYNONYM_EXISTS FROM CD_USERS CDU,
    ALL_SYNONYMS S, ALL_USERS U WHERE :B2 IN
    ('TYPE','TABLE','VIEW','FUNCTION','PROCEDURE','PACKAGE','SEQUENCE','QUEU
    E','SYNONYM') AND CDU.USER_TYPE = 'S' AND CDU.USER_NAME = U.USERNAME
    AND CDU.USER_NAME = S.OWNER AND :B1 = S.TABLE_NAME
    Please advise me as application team is chasing me like anything. what I can find out is that Cost is different in both databases.

    Sorry forr Late reply friends..
    below are the Explian plans for both databases:
                                                      BAD database
    PLAN_TABLE_OUTPUT
    SQL_ID  3bp3rynsds42r, child number 0
    SELECT CDU.USER_NAME, DECODE(:B2 , 'QUEUE','begin
    dbms_aqadm.grant_queue_privilege(''ALL'','''||:B1
    ||''','''||CDU.USER_NAME||''',true); end;', 'grant '||DECODE(:B2 ,
    'TABLE','SELECT,INSERT,UPDATE,DELETE'||DECODE(CDU.ADMIN,'Y',',REFERENCES
    ',''), 'VIEW',DECODE(:B3 ,NULL,'SELECT','SELECT,INSERT,UPDATE,DELETE'||D
    ECODE(CDU.ADMIN,'Y',',REFERENCES','')), 'TYPE','EXECUTE',
    'SEQUENCE','SELECT', 'EXECUTE')||' on
    '||PACK_UTILS.GET_SCHEMA_OWNER||'.'||:B1 ||' to
    "'||CDU.USER_NAME||'"'||DECODE(CDU.ADMIN,'Y',' WITH GRANT OPTION',''))
    PLAN_TABLE_OUTPUT
    AS GRANT_SOURCE, 'create or replace synonym
    "'||CDU.USER_NAME||'"."'||:B1 ||'" for
    "'||PACK_UTILS.GET_SCHEMA_OWNER||'"."'||:B1 ||'"' AS SYNONYM_SOURCE,
    NVL2( S.TABLE_NAME, 'Y', 'N' ) SYNONYM_EXISTS FROM CD_USERS CDU,
    ALL_SYNONYMS S, ALL_USERS U WHERE :B2 IN
    ('TYPE','TABLE','VIEW','FUNCTION','PROCEDURE','PACKAGE','SEQUENCE','QUEU
    E','SYNONYM') AND CDU.USER_TYPE = 'S' AND CDU.USER_NAME = U.USERNAME
    AND CDU.USER_NAME = S.OWNER AND :B1 = S.TABLE_NAME
    Plan hash value: 2404940060
    PLAN_TABLE_OUTPUT
    | Id  | Operation                                            | Name               | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                                     |                    |       |       |       |    94 (100)|          |
    |*  1 |  FILTER                                              |                    |       |       |       |            |          |
    |*  2 |   HASH JOIN                                          |                    |    81 |  6723 |       |    94   (0)| 00:00:01 |
    |   3 |    NESTED LOOPS OUTER                                |                    |    81 |  6480 |       |    91   (0)| 00:00:01 |
    |*  4 |     HASH JOIN                                        |                    |    81 |  3726 |       |    10   (0)| 00:00:01 |
    |*  5 |      HASH JOIN                                       |                    |   137 |  3699 |       |     7   (0)| 00:00:01 |
    |   6 |       TABLE ACCESS FULL                              | TS$                |     7 |    21 |       |     3   (0)| 00:00:01 |
    |*  7 |       TABLE ACCESS FULL                              | USER$              |   137 |  3288 |       |     4   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    |*  8 |      TABLE ACCESS FULL                               | CD_USERS           |    82 |  1558 |       |     3   (0)| 00:00:01 |
    |   9 |     VIEW                                             | ALL_SYNONYMS       |     1 |    34 |       |     1   (0)| 00:00:01 |
    |  10 |      SORT UNIQUE                                     |                    |       |       |       |            |          |
    |  11 |       UNION-ALL PARTITION                            |                    |       |       |       |            |          |
    |* 12 |        FILTER                                        |                    |       |       |       |            |          |
    |  13 |         NESTED LOOPS                                 |                    |     1 |   116 |       |    60   (0)| 00:00:01 |
    |  14 |          NESTED LOOPS                                |                    |     1 |    94 |       |    59   (0)| 00:00:01 |
    |  15 |           NESTED LOOPS                               |                    |    12 |   684 |       |    23   (0)| 00:00:01 |
    |  16 |            TABLE ACCESS BY INDEX ROWID               | USER$              |     1 |    19 |       |     1   (0)| 00:00:01 |
    |* 17 |             INDEX UNIQUE SCAN                        | I_USER1            |     1 |       |       |     0   (0)|          |
    |  18 |            TABLE ACCESS BY INDEX ROWID               | SYN$               |    12 |   456 |       |    22   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    |* 19 |             INDEX SKIP SCAN                          | I_SYN2             |    12 |       |       |    12   (0)| 00:00:01 |
    |* 20 |           TABLE ACCESS BY INDEX ROWID                | OBJ$               |     1 |    37 |       |     3   (0)| 00:00:01 |
    |* 21 |            INDEX RANGE SCAN                          | I_OBJ1             |     1 |       |       |     2   (0)| 00:00:01 |
    |* 22 |          INDEX RANGE SCAN                            | I_USER2            |     1 |    22 |       |     1   (0)| 00:00:01 |
    |* 23 |         FIXED TABLE FULL                             | X$KZSPR            |    17 |   119 |       |     0   (0)|          |
    |* 24 |         FILTER                                       |                    |       |       |       |            |          |
    |* 25 |          FILTER                                      |                    |       |       |       |            |          |
    |  26 |           NESTED LOOPS                               |                    |    27 |  2430 |       |     6   (0)| 00:00:01 |
    |  27 |            NESTED LOOPS                              |                    |     1 |    78 |       |     4   (0)| 00:00:01 |
    |  28 |             NESTED LOOPS                             |                    |     1 |    56 |       |     3   (0)| 00:00:01 |
    |  29 |              TABLE ACCESS BY INDEX ROWID             | USER$              |     1 |    19 |       |     1   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    |* 30 |               INDEX UNIQUE SCAN                      | I_USER1            |     1 |       |       |     0   (0)|          |
    |* 31 |              INDEX RANGE SCAN                        | I_OBJ5             |     1 |    37 |       |     2   (0)| 00:00:01 |
    |* 32 |             INDEX RANGE SCAN                         | I_USER2            |     1 |    22 |       |     1   (0)| 00:00:01 |
    |* 33 |            INDEX RANGE SCAN                          | I_OBJAUTH1         |    28 |   336 |       |     2   (0)| 00:00:01 |
    |* 34 |          FIXED TABLE FULL                            | X$KZSRO            |     1 |     3 |       |     0   (0)|          |
    |  35 |          NESTED LOOPS                                |                    |     1 |    30 |       |     3   (0)| 00:00:01 |
    |* 36 |           INDEX SKIP SCAN                            | I_USER2            |     1 |    20 |       |     1   (0)| 00:00:01 |
    |* 37 |           INDEX RANGE SCAN                           | I_OBJ4             |     1 |    10 |       |     2   (0)| 00:00:01 |
    |  38 |         NESTED LOOPS                                 |                    |     1 |    30 |       |     3   (0)| 00:00:01 |
    |* 39 |          INDEX SKIP SCAN                             | I_USER2            |     1 |    20 |       |     1   (0)| 00:00:01 |
    |* 40 |          INDEX RANGE SCAN                            | I_OBJ4             |     1 |    10 |       |     2   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    |* 41 |        FILTER                                        |                    |       |       |       |            |          |
    |  42 |         NESTED LOOPS                                 |                    |     1 |   129 |       |  4301   (2)| 00:00:39 |
    |  43 |          NESTED LOOPS                                |                    |     1 |   129 |       |  4301   (2)| 00:00:39 |
    |  44 |           NESTED LOOPS                               |                    |     1 |    91 |       |  4299   (2)| 00:00:39 |
    |  45 |            NESTED LOOPS                              |                    |     1 |    69 |       |  4298   (2)| 00:00:39 |
    |  46 |             NESTED LOOPS                             |                    |     2 |    64 |       |  4292   (2)| 00:00:39 |
    |  47 |              TABLE ACCESS BY INDEX ROWID             | USER$              |     1 |    19 |       |     1   (0)| 00:00:01 |
    |* 48 |               INDEX UNIQUE SCAN                      | I_USER1            |     1 |       |       |     0   (0)|          |
    |  49 |              VIEW                                    | _ALL_SYNONYMS_TREE |     2 |    26 |       |  4291   (2)| 00:00:39 |
    |* 50 |               CONNECT BY NO FILTERING WITH START-WITH|                    |       |       |       |            |          |
    |* 51 |                FILTER                                |                    |       |       |       |            |          |
    PLAN_TABLE_OUTPUT
    |* 52 |                 HASH JOIN                            |                    | 18370 |  2080K|       |  4291   (2)| 00:00:39 |
    |  53 |                  INDEX FULL SCAN                     | I_USER2            |   207 |  4554 |       |     1   (0)| 00:00:01 |
    |* 54 |                  HASH JOIN                           |                    | 18370 |  1686K|       |  4290   (2)| 00:00:39 |
    |  55 |                   TABLE ACCESS FULL                  | USER$              |   207 |  3933 |       |     4   (0)| 00:00:01 |
    |* 56 |                   HASH JOIN                          |                    |  2922K|   209M|    18M|  4269   (1)| 00:00:39 |
    |* 57 |                    INDEX FAST FULL SCAN              | I_OBJ2             |   387K|    13M|       |  1323   (1)| 00:00:12 |
    |  58 |                    TABLE ACCESS FULL                 | SYN$               |   400K|    14M|       |   566   (2)| 00:00:06 |
    |  59 |                 NESTED LOOPS                         |                    |     1 |    30 |       |     3   (0)| 00:00:01 |
    |* 60 |                  INDEX SKIP SCAN                     | I_USER2            |     1 |    20 |       |     1   (0)| 00:00:01 |
    |* 61 |                  INDEX RANGE SCAN                    | I_OBJ4             |     1 |    10 |       |     2   (0)| 00:00:01 |
    |* 62 |                FILTER                                |                    |       |       |       |            |          |
    PLAN_TABLE_OUTPUT
    |  63 |                 TABLE ACCESS BY INDEX ROWID          | SYN$               |     1 |    38 |       |     3   (0)| 00:00:01 |
    |* 64 |                  INDEX UNIQUE SCAN                   | I_SYN1             |     1 |       |       |     2   (0)| 00:00:01 |
    |* 65 |                 FILTER                               |                    |       |       |       |            |          |
    |* 66 |                  FILTER                              |                    |       |       |       |            |          |
    |  67 |                   NESTED LOOPS                       |                    |    27 |  2430 |       |     6   (0)| 00:00:01 |
    |  68 |                    NESTED LOOPS                      |                    |     1 |    78 |       |     4   (0)| 00:00:01 |
    |  69 |                     NESTED LOOPS                     |                    |     1 |    56 |       |     3   (0)| 00:00:01 |
    |  70 |                      TABLE ACCESS BY INDEX ROWID     | USER$              |     1 |    19 |       |     1   (0)| 00:00:01 |
    |* 71 |                       INDEX UNIQUE SCAN              | I_USER1            |     1 |       |       |     0   (0)|          |
    |* 72 |                      INDEX RANGE SCAN                | I_OBJ5             |     1 |    37 |       |     2   (0)| 00:00:01 |
    |* 73 |                     INDEX RANGE SCAN                 | I_USER2            |     1 |    22 |       |     1   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    |* 74 |                    INDEX RANGE SCAN                  | I_OBJAUTH1         |    28 |   336 |       |     2   (0)| 00:00:01 |
    |* 75 |                  FIXED TABLE FULL                    | X$KZSRO            |     1 |     3 |       |     0   (0)|          |
    |  76 |                  NESTED LOOPS                        |                    |     1 |    30 |       |     3   (0)| 00:00:01 |
    |* 77 |                   INDEX SKIP SCAN                    | I_USER2            |     1 |    20 |       |     1   (0)| 00:00:01 |
    |* 78 |                   INDEX RANGE SCAN                   | I_OBJ4             |     1 |    10 |       |     2   (0)| 00:00:01 |
    |* 79 |                 FIXED TABLE FULL                     | X$KZSPR            |    17 |   119 |       |     0   (0)|          |
    |* 80 |             TABLE ACCESS BY INDEX ROWID              | OBJ$               |     1 |    37 |       |     3   (0)| 00:00:01 |
    |* 81 |              INDEX RANGE SCAN                        | I_OBJ1             |     1 |       |       |     2   (0)| 00:00:01 |
    |* 82 |            INDEX RANGE SCAN                          | I_USER2            |     1 |    22 |       |     1   (0)| 00:00:01 |
    |* 83 |           INDEX UNIQUE SCAN                          | I_SYN1             |     1 |       |       |     1   (0)| 00:00:01 |
    |* 84 |          TABLE ACCESS BY INDEX ROWID                 | SYN$               |     1 |    38 |       |     2   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    |  85 |         NESTED LOOPS                                 |                    |     1 |    30 |       |     3   (0)| 00:00:01 |
    |* 86 |          INDEX SKIP SCAN                             | I_USER2            |     1 |    20 |       |     1   (0)| 00:00:01 |
    |* 87 |          INDEX RANGE SCAN                            | I_OBJ4             |     1 |    10 |       |     2   (0)| 00:00:01 |
    |  88 |    TABLE ACCESS FULL                                 | TS$                |     7 |    21 |       |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter((:B2='TYPE' OR :B2='TABLE' OR :B2='VIEW' OR :B2='FUNCTION' OR :B2='PROCEDURE' OR :B2='PACKAGE' OR
                  :B2='SEQUENCE' OR :B2='QUEUE' OR :B2='SYNONYM'))
    PLAN_TABLE_OUTPUT
       2 - access("U"."TEMPTS#"="TTS"."TS#")
       4 - access("CDU"."USER_NAME"="U"."NAME")
       5 - access("U"."DATATS#"="DTS"."TS#")
       7 - filter("U"."TYPE#"=1)
       8 - filter("CDU"."USER_TYPE"='S')
      12 - filter(((INTERNAL_FUNCTION("O"."SPARE3") OR ("S"."NODE" IS NULL AND  IS NOT NULL) OR  IS NOT NULL) 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 (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)))
    PLAN_TABLE_OUTPUT
      17 - access("U"."NAME"="CDU"."USER_NAME")
      19 - access("S"."NAME"=:B1)
           filter("S"."NAME"=:B1)
      20 - filter("O"."SPARE3"="U"."USER#")
      21 - access("O"."OBJ#"="S"."OBJ#" AND "O"."TYPE#"=5)
           filter("O"."TYPE#"=5)
      22 - access("O"."OWNER#"="U"."USER#")
      23 - filter((((-"KZSPRPRV")=(-45) OR (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR
                  (-"KZSPRPRV")=(-50)) AND "INST_ID"=USERENV('INSTANCE')))
      24 - filter((("BA"."GRANTOR#"=USERENV('SCHEMAID') OR  IS NOT NULL) 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
    PLAN_TABLE_OUTPUT
                  "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)))))
      25 - filter(:B1 IS NULL)
      30 - access("BU"."NAME"=:B1)
      31 - access("BU"."USER#"="O"."SPARE3" AND "O"."NAME"=:B1)
      32 - access("O"."OWNER#"="U"."USER#")
      33 - access("BA"."OBJ#"="O"."OBJ#")
      34 - filter("KZSROROL"=:B1)
      36 - access("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')))
    PLAN_TABLE_OUTPUT
           filter(("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))))
      37 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88 AND "O2"."OWNER#"="U2"."USER#")
      39 - 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'))))
      40 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88 AND "O2"."OWNER#"="U2"."USER#")
      41 - filter((("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
                  (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))
      48 - access("U"."NAME"="CDU"."USER_NAME")
    PLAN_TABLE_OUTPUT
      50 - access("S"."BASE_SYN_ID"=PRIOR NULL)
           filter( IS NOT NULL)
      51 - filter((("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
                  (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))
      52 - access("O"."OWNER#"="U"."USER#")
      54 - access("S"."OWNER"="BU"."NAME" AND "BU"."USER#"="O"."SPARE3")
      56 - access("S"."NAME"="O"."NAME")
      57 - filter("O"."TYPE#"=5)
    PLAN_TABLE_OUTPUT
      60 - 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'))))
      61 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88 AND "O2"."OWNER#"="U2"."USER#")
      62 - filter(( IS NOT NULL OR ("S"."NODE" IS NULL AND  IS NOT NULL)))
      64 - access("S"."OBJ#"=:B1)
      65 - filter((("BA"."GRANTOR#"=USERENV('SCHEMAID') OR  IS NOT NULL) 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)))))
    PLAN_TABLE_OUTPUT
      66 - filter(:B1 IS NULL)
      71 - access("BU"."NAME"=:B1)
      72 - access("BU"."USER#"="O"."SPARE3" AND "O"."NAME"=:B1)
      73 - access("O"."OWNER#"="U"."USER#")
      74 - access("BA"."OBJ#"="O"."OBJ#")
      75 - filter("KZSROROL"=:B1)
      77 - 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'))))
      78 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88 AND "O2"."OWNER#"="U2"."USER#")
      79 - filter((((-"KZSPRPRV")=(-45) OR (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR
                  (-"KZSPRPRV")=(-50)) AND "INST_ID"=USERENV('INSTANCE')))
    PLAN_TABLE_OUTPUT
      80 - filter("O"."SPARE3"="U"."USER#")
      81 - access("O"."OBJ#"="ST"."SYN_ID" AND "O"."TYPE#"=5)
           filter("O"."TYPE#"=5)
      82 - access("O"."OWNER#"="U"."USER#")
      83 - access("S"."OBJ#"="ST"."SYN_ID")
           filter("O"."OBJ#"="S"."OBJ#")
      84 - filter("S"."NAME"=:B1)
      86 - 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'))))
      87 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88 AND "O2"."OWNER#"="U2"."USER#")
    209 rows selected
    ==============================================================================================
                                                                     Good one
    PLAN_TABLE_OUTPUT
    SQL_ID  3bp3rynsds42r, child number 0
    SELECT CDU.USER_NAME, DECODE(:B2 , 'QUEUE','begin
    dbms_aqadm.grant_queue_privilege(''ALL'','''||:B1
    ||''','''||CDU.USER_NAME||''',true); end;', 'grant '||DECODE(:B2 ,
    'TABLE','SELECT,INSERT,UPDATE,DELETE'||DECODE(CDU.ADMIN,'Y',',REFERENCES
    ',''), 'VIEW',DECODE(:B3 ,NULL,'SELECT','SELECT,INSERT,UPDATE,DELETE'||D
    ECODE(CDU.ADMIN,'Y',',REFERENCES','')), 'TYPE','EXECUTE',
    'SEQUENCE','SELECT', 'EXECUTE')||' on
    '||PACK_UTILS.GET_SCHEMA_OWNER||'.'||:B1 ||' to
    "'||CDU.USER_NAME||'"'||DECODE(CDU.ADMIN,'Y',' WITH GRANT OPTION',''))
    PLAN_TABLE_OUTPUT
    AS GRANT_SOURCE, 'create or replace synonym
    "'||CDU.USER_NAME||'"."'||:B1 ||'" for
    "'||PACK_UTILS.GET_SCHEMA_OWNER||'"."'||:B1 ||'"' AS SYNONYM_SOURCE,
    NVL2( S.TABLE_NAME, 'Y', 'N' ) SYNONYM_EXISTS FROM CD_USERS CDU,
    ALL_SYNONYMS S, ALL_USERS U WHERE :B2 IN
    ('TYPE','TABLE','VIEW','FUNCTION','PROCEDURE','PACKAGE','SEQUENCE','QUEU
    E','SYNONYM') AND CDU.USER_TYPE = 'S' AND CDU.USER_NAME = U.USERNAME
    AND CDU.USER_NAME = S.OWNER AND :B1 = S.TABLE_NAME
    Plan hash value: 2146531909
    PLAN_TABLE_OUTPUT
    | Id  | Operation                                          | Name               | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                                   |                    |       |       |       |    15 (100)|          |
    |*  1 |  FILTER                                            |                    |       |       |       |            |          |
    |   2 |   NESTED LOOPS OUTER                               |                    |     3 |   273 |       |    15   (0)| 00:00:01 |
    |   3 |    NESTED LOOPS                                    |                    |     3 |   153 |       |    12   (0)| 00:00:01 |
    |   4 |     NESTED LOOPS                                   |                    |     3 |   144 |       |     9   (0)| 00:00:01 |
    |   5 |      NESTED LOOPS                                  |                    |     3 |   135 |       |     6   (0)| 00:00:01 |
    |*  6 |       TABLE ACCESS FULL                            | USER$              |    55 |  1375 |       |     4   (0)| 00:00:01 |
    |*  7 |       TABLE ACCESS BY INDEX ROWID                  | CD_USERS           |     1 |    20 |       |     1   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    |*  8 |        INDEX UNIQUE SCAN                           | I1_CD_USERS        |     1 |       |       |     0   (0)|          |
    |   9 |      TABLE ACCESS CLUSTER                          | TS$                |     1 |     3 |       |     1   (0)| 00:00:01 |
    |* 10 |       INDEX UNIQUE SCAN                            | I_TS#              |     1 |       |       |     0   (0)|          |
    |  11 |     TABLE ACCESS CLUSTER                           | TS$                |     1 |     3 |       |     1   (0)| 00:00:01 |
    |* 12 |      INDEX UNIQUE SCAN                             | I_TS#              |     1 |       |       |     0   (0)|          |
    |  13 |    VIEW                                            | ALL_SYNONYMS       |     1 |    40 |       |     1   (0)| 00:00:01 |
    |  14 |     SORT UNIQUE                                    |                    |       |       |       |            |          |
    |  15 |      UNION-ALL PARTITION                           |                    |       |       |       |            |          |
    |* 16 |       FILTER                                       |                    |       |       |       |            |          |
    |  17 |        NESTED LOOPS                                |                    |     1 |   116 |       |    19   (0)| 00:00:01 |
    |  18 |         NESTED LOOPS                               |                    |     1 |    94 |       |    18   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    |  19 |          NESTED LOOPS                              |                    |     1 |    56 |       |    15   (0)| 00:00:01 |
    |  20 |           TABLE ACCESS BY INDEX ROWID              | USER$              |     1 |    20 |       |     1   (0)| 00:00:01 |
    |* 21 |            INDEX UNIQUE SCAN                       | I_USER1            |     1 |       |       |     0   (0)|          |
    |  22 |           TABLE ACCESS BY INDEX ROWID              | SYN$               |     1 |    36 |       |    14   (0)| 00:00:01 |
    |* 23 |            INDEX SKIP SCAN                         | I_SYN2             |     1 |       |       |    12   (0)| 00:00:01 |
    |* 24 |          TABLE ACCESS BY INDEX ROWID               | OBJ$               |     1 |    38 |       |     3   (0)| 00:00:01 |
    |* 25 |           INDEX RANGE SCAN                         | I_OBJ1             |     1 |       |       |     2   (0)| 00:00:01 |
    |* 26 |         INDEX RANGE SCAN                           | I_USER2            |     1 |    22 |       |     1   (0)| 00:00:01 |
    |* 27 |        FIXED TABLE FULL                            | X$KZSPR            |    17 |   119 |       |     0   (0)|          |
    |* 28 |        FILTER                                      |                    |       |       |       |            |          |
    |* 29 |         FILTER                                     |                    |       |       |       |            |          |
    PLAN_TABLE_OUTPUT
    |  30 |          NESTED LOOPS                              |                    |     3 |   279 |       |     5   (0)| 00:00:01 |
    |  31 |           NESTED LOOPS                             |                    |     1 |    80 |       |     4   (0)| 00:00:01 |
    |  32 |            NESTED LOOPS                            |                    |     1 |    58 |       |     3   (0)| 00:00:01 |
    |  33 |             TABLE ACCESS BY INDEX ROWID            | USER$              |     1 |    20 |       |     1   (0)| 00:00:01 |
    |* 34 |              INDEX UNIQUE SCAN                     | I_USER1            |     1 |       |       |     0   (0)|          |
    |* 35 |             INDEX RANGE SCAN                       | I_OBJ5             |     1 |    38 |       |     2   (0)| 00:00:01 |
    |* 36 |            INDEX RANGE SCAN                        | I_USER2            |     1 |    22 |       |     1   (0)| 00:00:01 |
    |* 37 |           INDEX RANGE SCAN                         | I_OBJAUTH1         |     3 |    39 |       |     1   (0)| 00:00:01 |
    |* 38 |         FIXED TABLE FULL                           | X$KZSRO            |     1 |     3 |       |     0   (0)|          |
    |  39 |         NESTED LOOPS                               |                    |     1 |    32 |       |     3   (0)| 00:00:01 |
    |* 40 |          INDEX SKIP SCAN                           | I_USER2            |     1 |    20 |       |     1   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    |* 41 |          INDEX RANGE SCAN                          | I_OBJ4             |     1 |    12 |       |     2   (0)| 00:00:01 |
    |  42 |        NESTED LOOPS                                |                    |     1 |    32 |       |     3   (0)| 00:00:01 |
    |* 43 |         INDEX SKIP SCAN                            | I_USER2            |     1 |    20 |       |     1   (0)| 00:00:01 |
    |* 44 |         INDEX RANGE SCAN                           | I_OBJ4             |     1 |    12 |       |     2   (0)| 00:00:01 |
    |* 45 |       FILTER                                       |                    |       |       |       |            |          |
    |  46 |        NESTED LOOPS                                |                    |     1 |   129 |       |  1065   (1)| 00:00:13 |
    |  47 |         NESTED LOOPS                               |                    |     1 |   107 |       |  1064   (1)| 00:00:13 |
    |  48 |          NESTED LOOPS                              |                    |     1 |    69 |       |  1061   (1)| 00:00:13 |
    |  49 |           NESTED LOOPS                             |                    |     2 |    66 |       |  1059   (1)| 00:00:13 |
    |  50 |            TABLE ACCESS BY INDEX ROWID             | USER$              |     1 |    20 |       |     1   (0)| 00:00:01 |
    |* 51 |             INDEX UNIQUE SCAN                      | I_USER1            |     1 |       |       |     0   (0)|          |
    PLAN_TABLE_OUTPUT
    |  52 |            VIEW                                    | _ALL_SYNONYMS_TREE |     2 |    26 |       |  1058   (1)| 00:00:13 |
    |* 53 |             CONNECT BY NO FILTERING WITH START-WITH|                    |       |       |       |            |          |
    |* 54 |              FILTER                                |                    |       |       |       |            |          |
    |* 55 |               HASH JOIN                            |                    |   705 | 81780 |       |  1058   (1)| 00:00:13 |
    |  56 |                INDEX FULL SCAN                     | I_USER2            |   124 |  2728 |       |     1   (0)| 00:00:01 |
    |* 57 |                HASH JOIN                           |                    |   705 | 66270 |       |  1057   (1)| 00:00:13 |
    |  58 |                 TABLE ACCESS FULL                  | USER$              |   124 |  2480 |       |     4   (0)| 00:00:01 |
    |* 59 |                 HASH JOIN                          |                    | 66964 |  4839K|  2232K|  1052   (1)| 00:00:13 |
    |  60 |                  TABLE ACCESS FULL                 | SYN$               | 47615 |  1673K|       |    78   (2)| 00:00:01 |
    |* 61 |                  INDEX FAST FULL SCAN              | I_OBJ5             | 47862 |  1776K|       |   752   (1)| 00:00:10 |
    |  62 |               NESTED LOOPS                         |                    |     1 |    32 |       |     3   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    |* 63 |                INDEX SKIP SCAN                     | I_USER2            |     1 |    20 |       |     1   (0)| 00:00:01 |
    |* 64 |                INDEX RANGE SCAN                    | I_OBJ4             |     1 |    12 |       |     2   (0)| 00:00:01 |
    |* 65 |              FILTER                                |                    |       |       |       |            |          |
    |  66 |               TABLE ACCESS BY INDEX ROWID          | SYN$               |     1 |    36 |       |     2   (0)| 00:00:01 |
    |* 67 |                INDEX UNIQUE SCAN                   | I_SYN1             |     1 |       |       |     1   (0)| 00:00:01 |
    |* 68 |               FILTER                               |                    |       |       |       |            |          |
    |* 69 |                FILTER                              |                    |       |       |       |            |          |
    |  70 |                 NESTED LOOPS                       |                    |     3 |   279 |       |     5   (0)| 00:00:01 |
    |  71 |                  NESTED LOOPS                      |                    |     1 |    80 |       |     4   (0)| 00:00:01 |
    |  72 |                   NESTED LOOPS                     |                    |     1 |    58 |       |     3   (0)| 00:00:01 |
    |  73 |                    TABLE ACCESS BY INDEX ROWID     | USER$              |     1 |    20 |       |     1   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    |* 74 |                     INDEX UNIQUE SCAN              | I_USER1            |     1 |       |       |     0   (0)|          |
    |* 75 |                    INDEX RANGE SCAN                | I_OBJ5             |     1 |    38 |       |     2   (0)| 00:00:01 |
    |* 76 |                   INDEX RANGE SCAN                 | I_USER2            |     1 |    22 |       |     1   (0)| 00:00:01 |
    |* 77 |                  INDEX RANGE SCAN                  | I_OBJAUTH1         |     3 |    39 |       |     1   (0)| 00:00:01 |
    |* 78 |                FIXED TABLE FULL                    | X$KZSRO            |     1 |     3 |       |     0   (0)|          |
    |  79 |                NESTED LOOPS                        |                    |     1 |    32 |       |     3   (0)| 00:00:01 |
    |* 80 |                 INDEX SKIP SCAN                    | I_USER2            |     1 |    20 |       |     1   (0)| 00:00:01 |
    |* 81 |                 INDEX RANGE SCAN                   | I_OBJ4             |     1 |    12 |       |     2   (0)| 00:00:01 |
    |* 82 |               FIXED TABLE FULL                     | X$KZSPR            |    17 |   119 |       |     0   (0)|          |
    |* 83 |           TABLE ACCESS BY INDEX ROWID              | SYN$               |     1 |    36 |       |     1   (0)| 00:00:01 |
    |* 84 |            INDEX UNIQUE SCAN                       | I_SYN1             |     1 |       |       |     0   (0)|          |
    PLAN_TABLE_OUTPUT
    |* 85 |          TABLE ACCESS BY INDEX ROWID               | OBJ$               |     1 |    38 |       |     3   (0)| 00:00:01 |
    |* 86 |           INDEX RANGE SCAN                         | I_OBJ1             |     1 |       |       |     2   (0)| 00:00:01 |
    |* 87 |         INDEX RANGE SCAN                           | I_USER2            |     1 |    22 |       |     1   (0)| 00:00:01 |
    |  88 |        NESTED LOOPS                                |                    |     1 |    32 |       |     3   (0)| 00:00:01 |
    |* 89 |         INDEX SKIP SCAN                            | I_USER2            |     1 |    20 |       |     1   (0)| 00:00:01 |
    |* 90 |         INDEX RANGE SCAN                           | I_OBJ4             |     1 |    12 |       |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
       1 - filter((:B2='TYPE' OR :B2='TABLE' OR :B2='VIEW' OR :B2='FUNCTION' OR :B2='PROCEDURE' OR :B2='PACKAGE' OR
                  :B2='SEQUENCE' OR :B2='QUEUE' OR :B2='SYNONYM'))
       6 - filter("U"."TYPE#"=1)
       7 - filter("CDU"."USER_TYPE"='S')
       8 - access("CDU"."USER_NAME"="U"."NAME")
      10 - access("U"."DATATS#"="DTS"."TS#")
      12 - access("U"."TEMPTS#"="TTS"."TS#")
      16 - filter(((INTERNAL_FUNCTION("O"."SPARE3") OR ("S"."NODE" IS NULL AND  IS NOT NULL) OR  IS NOT NULL) 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 (SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE' AND
    PLAN_TABLE_OUTPUT
                  "U"."TYPE#"<>2) OR ("U"."TYPE#"=2 AND "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))) OR  IS NOT
                  NULL)))
      21 - access("U"."NAME"="CDU"."USER_NAME")
      23 - access("S"."NAME"=:B1)
           filter("S"."NAME"=:B1)
      24 - filter("O"."SPARE3"="U"."USER#")
      25 - access("O"."OBJ#"="S"."OBJ#" AND "O"."TYPE#"=5)
           filter("O"."TYPE#"=5)
      26 - access("O"."OWNER#"="U"."USER#")
      27 - filter((((-"KZSPRPRV")=(-45) OR (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR
                  (-"KZSPRPRV")=(-50)) AND "INST_ID"=USERENV('INSTANCE')))
    PLAN_TABLE_OUTPUT
      28 - filter((("BA"."GRANTOR#"=USERENV('SCHEMAID') OR  IS NOT NULL) 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)))))
      29 - filter(:B1 IS NULL)
      34 - access("BU"."NAME"=:B1)
      35 - access("BU"."USER#"="O"."SPARE3" AND "O"."NAME"=:B1)
      36 - access("O"."OWNER#"="U"."USER#")
      37 - access("BA"."OBJ#"="O"."OBJ#")
    PLAN_TABLE_OUTPUT
      38 - filter("KZSROROL"=:B1)
      40 - 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'))))
      41 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88 AND "O2"."OWNER#"="U2"."USER#")
      43 - 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'))))
      44 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88 AND "O2"."OWNER#"="U2"."USER#")
      45 - filter((("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
                  (SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE' AND "U"."TYPE#"<>2) OR ("U"."TYPE#"=2 AND
    PLAN_TABLE_OUTPUT
                  "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))) OR  IS NOT NULL))
      51 - access("U"."NAME"="CDU"."USER_NAME")
      53 - access("S"."BASE_SYN_ID"=PRIOR NULL)
           filter( IS NOT NULL)
      54 - filter((("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
                  (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))
      55 - access("O"."OWNER#"="U"."USER#")
      57 - access("S"."OWNER"="BU"."NAME" AND "BU"."USER#"="O"."SPARE3")
    PLAN_TABLE_OUTPUT
      59 - access("S"."NAME"="O"."NAME")
      61 - filter("O"."TYPE#"=5)
      63 - 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'))))
      64 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88 AND "O2"."OWNER#"="U2"."USER#")
      65 - filter(( IS NOT NULL OR ("S"."NODE" IS NULL AND  IS NOT NULL)))
      67 - access("S"."OBJ#"=:B1)
      68 - filter((("BA"."GRANTOR#"=USERENV('SCHEMAID') OR  IS NOT NULL) 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
    PLAN_TABLE_OUTPUT
                  ((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)))))
      69 - filter(:B1 IS NULL)
      74 - access("BU"."NAME"=:B1)
      75 - access("BU"."USER#"="O"."SPARE3" AND "O"."NAME"=:B1)
      76 - access("O"."OWNER#"="U"."USER#")
      77 - access("BA"."OBJ#"="O"."OBJ#")
      78 - filter("KZSROROL"=:B1)
      80 - 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'))))
      81 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TY

  • Oracle Sql Query issue Running on Different DB Version

    Hello All,
    I have come into situation where we are pruning sql queries on different DB version of Oracle and have performance issue. Let me tell you in brief and i really appreciate for your prompt response as its very imperative stuff.
    I have a query which is running on a DB of version 7.3.4 and it takes around 30 mins where as the same query when run on 8i it takes 15sec., its a huge difference. I have run the statistics to analyze on 7.3 and its comparatively very high. Question here is, the sql query trys to select data from same schema table and 2 tables from another DB using DB link and 2 other tables from another DB using DB link.So,how can we optimize this stuff and achieve this run as same time as 8i DB in 7.3. Hope i am clear about my question, Eagerly waiting for your replies.
    Thanks in Advance.
    Message was edited by:
    Ram8

    Difficult to be sure without any more detailed information, but I suspect that O7 is in effect copying the remote tables to local temp space, then joining; 8i is factoring out a better query to send to the remote DBs, which does as much work as possible on the remote DB before shipping remaining rows back to local.
    You should be able to use EXPLAIN PLAN to identify what SQL is being shipped to the remote DB, If you can't (and it's been quite a while since I tried DB links or O7) then get the remote DBs to yourself, and set SQL_TRACE on for the remote instances. Execute the query and then examine the remote trace files, And don't forget to turn off the tracing when you're done.
    Of course it could just be that the CBO got better,,,
    HTH - if not, post your query and plans for the local db, and the remote queries.
    Regards Nigel

  • XML SQL query not displaying result in SQLPLUS

    Have a registered schema and 1 xml document successfully inserted using Oracle 10.2.0.3.0
    I then run the following query:
    select extract(object_value,'/warehouse/warehousename')from xwarehouses;
    Expecting 1 record to be returned in SQLPLUS but get the following result:
    EXTRACT(OBJECT_VALUE,'/WAREHOUSE/WAREHOUSENAME')
    1 row selected.
    Can anyone shed any light? Is it a setting in SQLPlus

    Thanks A Non
    I still cannot see where I am going wrong!
    The schema registers okay. My inserts work fine.
    --register the schema
    begin
    dbms_xmlschema.registerSchema(
    'http://www.oracle.com/xwarehouses.xsd',
    '<schema xmlns="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.oracle.com/xwarehouses.xsd"
    xmlns:who="http://www.oracle.com/xwarehouses.xsd"
    version="1.0"
    elementFormDefault="unqualified">
    <simpleType name="RentalType">
    <restriction base="string">
    <enumeration value="Rented"/>
    <enumeration value="Owned"/>
    </restriction>
    </simpleType>
    <simpleType name="ParkingType">
    <restriction base="string">
    <enumeration value="Street"/>
    <enumeration value="Lot"/>
    </restriction>
    </simpleType>
    <element name = "Warehouse">
    <complexType>
    <sequence>
    <element name = "WarehouseId" type = "positiveInteger"/>
    <element name = "WarehouseName" type = "string"/>
    <element name = "Building" type = "who:RentalType"/>
    <element name = "Area" type = "positiveInteger"/>
    <element name = "Docks" type = "positiveInteger"/>
    <element name = "DockType" type = "string"/>
    <element name = "WaterAccess" type = "boolean"/>
    <element name = "RailAccess" type = "boolean"/>
    <element name = "Parking" type = "who:ParkingType"/>
    <element name = "VClearance" type = "positiveInteger"/>
    </sequence>
    </complexType>
    </element>
    </schema>',
    TRUE, TRUE, FALSE, FALSE);
    end;
    --create the table
    CREATE TABLE xwarehouses OF XMLTYPE
    XMLSCHEMA "http://www.oracle.com/xwarehouses.xsd"
    ELEMENT "Warehouse";
    --Insert
    INSERT INTO xwarehouses VALUES(
    xmltype.createxml('<?xml version="1.0"?>
    <who:Warehouse xmlns:who="http://www.oracle.com/xwarehouses.xsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
    xs:schemaLocation="http://www.oracle.com/xwarehouses.xsd
    http://www.oracle.com/xwarehouses.xsd">
    <WarehouseId>1</WarehouseId>
    <WarehouseName>Southlake, Texas</WarehouseName>
    <Building>Owned</Building>
    <Area>25000</Area>
    <Docks>2</Docks>
    <DockType>Rear load</DockType>
    <WaterAccess>true</WaterAccess>
    <RailAccess>false</RailAccess>
    <Parking>Street</Parking>
    <VClearance>10</VClearance>
    </who:Warehouse>'));
    I don't know if you see the error
    Thanks again.

  • How to get report (SQL Query) generating Run Time

    There is a Standard report of Payroll which show employee transfer information on the bases of location, grade job or organization, now to get actual query which is generated by run time in report builder including whether single column parameter or lexical parameter " because currently the query in not complicate but the parameter and lexical parameter is much more due to this not quite easy to under stand just copy past it into toad or pl/sql developer,
    Kindly share your experience to get such kind of query in you working time.
    thanks

    Here i try to explain contain of query.
    Parameter
    P_DEPTNO = 10
    P_WHERE_CLAUSE := ' AND EMPNO IS NOT NULL AND SALARY > 100'
    SELECT * FROM EMP
    WHERE DEPTNO = P_DEPTNO
    &P_WHERE_CLAUSE
    REPROT WILL GENERATE QUERY AT RUN TIME IS LIKE THAT
    SELECT * FROM EMP
    WHERE DEPTNO = 10
    AND EMPNO IS NOT NULL AND SALARY > 100
    Now i want to get this query out(Run time) by doing any oracle database feature or sth similar.
    thanks

  • SQL Query if or case omit fields but not line.

    I have the below SQL Query my goal is to not show Aging or Storage Date if QTY is greater than 0. 
    I know I can omit the line but I still want to show just not those two fields is this possible?
    Select sl.SKU, sl.LOC, (editdate) AS "Storage Date", CAST(sysdate-editdate AS DECIMAL(10,2)) AS Aging, sl.QTY, sl.QTYALLOCATED
    From skuxloc sl
    Where sl.SKU in ('315A6112-29','315A6112-33')
    This is what I'm looking for:
    Work Smarter Not Harder

    Are you working with OracleSQL, There is no sysdate in SQL Server.
    Select sl.SKU, sl.LOC,
    case when sl.QTY =0 then '' else editdate end AS 'Storage Date',
    case when sl.QTY =0 then '' else CAST(sysdate-editdate AS DECIMAL(10,2)) END
    AS Aging,
    sl.QTY, sl.QTYALLOCATED
    From skuxloc sl
    Where sl.SKU in ('315A6112-29','315A6112-33')
    If you are working with Oracle, You can try decode.
    http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions040.htm
    http://www.dba-oracle.com/t_decode_function.htm
    --Prashanth

  • Can we change/Modify BI server generated Sql query and run to fetch data

    Hi,
    My client is saying that there is an option to modify bi server generated sql query to fetch data from source.
    question:As a request is made in presentation services, A dynamic sql query is generated and fetches data from source. all this is loggedin Nqlquery log..well can we change/modify the sql query generated and run modified sql query to fetch data from source. ., if so how? if not why?
    Thanks in advance
    Edited by: user10794468 on Jun 16, 2009 6:29 PM
    Edited by: user10794468 on Aug 12, 2009 6:58 PM

    Thank you so much for your reply..
    ..Can we also modify sql query generated by bi server to fetech data. the query's which we see in query log file..

  • Which query will run faster

    Hi,
    I have following two tables:
    SQL> desc customers
    Name Null? Type
    ID NOT NULL NUMBER
    NAME VARCHAR2(20)
    SQL> desc orders
    Name Null? Type
    CUST_ID NUMBER
    ARTICLE_NR VARCHAR2(20)
    PRICE NUMBER(5,2)
    I want to find each customer's order with the highest price along with its respective article number and the customer's name.
    Please let me know, which of the following query will work fast and why:
    SELECT c.NAME, o.article_nr, o.price
    FROM customers c,
    (SELECT cust_id, article_nr, price,
    ROW_NUMBER () OVER (PARTITION BY cust_id ORDER BY price DESC)
    r
    FROM orders) o
    WHERE o.r = 1 AND c.ID = o.cust_id
    SELECT NAME, article_nr, price
    FROM orders o, customers c
    WHERE c.ID = o.cust_id
    AND (o.cust_id, price) IN (SELECT cust_id, MAX (price)
    FROM orders
    GROUP BY cust_id);
    Thanks.

    Your second version is selecting twice from the same table (orders). The first version needs only one read over this table. So there is a good chance that the first version is faster than the second.
    However there is always a possibility depending on indexes etc. that it is otherwise.

  • LSMW fails when run in B/G but works in Frontend..why?

    Hi All,
    i am trying to runa batch process by LSMW, my files are accurate, no problem with them, everything works fine but it fails when run in BG..works absolutely fine in front end. whats the diff with running in B/G?
    same thing happens when i am trying to execute an RFC thru SAP JCO, it works when debugger is on 9i guess switching on debugger is similar to running in B/G) but it doesnt work when debugger is off. but when i execute that RFC directly in se37 from SAP gui it works fine..fails when connected to JCO..
    i am not having this issue with r/3 4.6c or mySAP ECC.6.0  i have this issue only in r/3 4.7.
    has anyone faced the similar situtaion? pls help.
    thanks.
    p.s if this may help. the RFC and LSMW error both are pertaining to change in address of US employees.( infotype 0006)

    Applying SAP note 928273 Solved this issue.
    thank you.

  • Query runs fast in DB but slow in OBIEE

    Hello guys
    I am running some reports on the dashboard, which takes forever to come up. I capture the generated SQL and ran it in Toad, it would take only less than 2 mins to return the data.
    What area of OBIEE configuration should I check to see what's happening?
    Much thanks

    Thanks.. Let me show you the query I am executing:
    select T1011554.PECODE as c1,
    T1011581.DATE as c2,
    T1011581.DAYOFWEEK as c3
    from
    RD_TOT.TRANSACTIONTYPE T1011554 /*Transaction */ ,
    RD_TOT.V_FACTS_SNAPSHOT_12 T1011580 /* Facts */ ,
    RD_TOT.DATES T1011581 /* Date */
    where ( T1011554.TRANSACTIONTYPEID = T1011580.TRANSACTIONTYPEID and T1011554.TRANSACTIONTYPECODE = '2' and T1011581.DAYOFWEEK = 'Monday' and T1011580.DOCUMENTCOMPANY = T1011581.COMPANYNUMBER and T1011580.SNAPSHOTDATE = T1011581.DATES and T1011581.DATES < TO_DATE('2009-10-28' , 'YYYY-MM-DD') )
    When I run this query in Toad, it takes less than 30s to return, but from OBIEE, it's taking forever.. I am using Oracle 10g as DB... I am sure there are a lot of rows being fetched, because using the result I am getting in toad, if I do a record count, that process will take forever again..
    There might be some configuration setup I need to do in OBIEE or config file. This is just my feelings, but I'd like to hear any of your thoughts and suggestions..
    Much appreciated!
    Thanks

  • SBO SQL Query outputs zero values as nulls but need the zeros

    Hi all,
    I'm having a problem with a query I'm writing in SBO where if the field contents are zero, these are output as null.
    I have a field for the stock usage on sales orders and ont too for production orders, but if I add these together they only provide a result if both columns contain a numeric value.
    I've tried adding "0" to the column value, adding and subtracting "1" and also multiplying the value by "1" but still no joy.
    I have also tried adding a "cast" statement to the column, but that doesnt seem to have an effect either (I think as this is more an output function).
    I need to be able to use these columns as separate displays in addition to being used in a further column as part of a calculation.
    If anyone has an idea how I can output a true zero value as opposed to a null value your help would be appreciated.
    Cheers,
    J

    Hello Julian,
    You could try to use a CASE Statement as I have shown below and test this will the SQL below.  If you use the T0.LineNum without any CASE or CAST the LineNum 0 will show as blank in SAP.
    SELECT
    CASE WHEN T0.LineNum != 0 THEN CAST(T0.LineNum AS VARCHAR(10)) ELSE '0' END AS 'Row Number',
    T0.ItemCode AS 'Item No.', T0.BaseQty AS 'Base Quantity', T0.PlannedQty AS 'Planned Quantity - Rows'  FROM  [dbo\].[WOR1\] T0

  • Sql query to identify transports in dev but not in prod

    I use sqlplus to select fields from saperp.e070v so I can compare transports in prod with those in qa. The purpose is to identify those transports that I need to run when I H-copy prod to QA. I'm using this where clause (TRFUNCTION='K' OR TRFUNCTION='W') . Should I look at TRSTATUS? I'd appreciate any recommendations or ideas. I do not have access to ABAP.

    Thanks Markus.
    Here are the distinct codes I found. Are there any ot these That I need to be concerned about? Is there a Key/Legend for these?
    SQL> select distinct trstatus from saperp.e070v;
    T
    R
    D
    O
    SQL> select distinct trfunction from saperp.e070v;
    T
    W
    R
    P
    K
    D
    Q
    M
    T
    X
    F
    S
    T
    G
    12 rows selected.
    SQL> describe saperp.e070v;
    Name                                      Null?    Type
    TRKORR                                    NOT NULL VARCHAR2(20)
    TRFUNCTION                                NOT NULL VARCHAR2(1)
    TRSTATUS                                  NOT NULL VARCHAR2(1)
    TARSYSTEM                                 NOT NULL VARCHAR2(10)
    AS4USER                                   NOT NULL VARCHAR2(12)
    AS4DATE                                   NOT NULL VARCHAR2(8)
    AS4TIME                                   NOT NULL VARCHAR2(6)
    STRKORR                                   NOT NULL VARCHAR2(20)
    LANGU                                     NOT NULL VARCHAR2(1)
    AS4TEXT                                   NOT NULL VARCHAR2(60)
    CLIENT                                    NOT NULL VARCHAR2(3)
    SQL>
    F
    S
    T
    G
    12 rows selected.
    SQL> describe saperp.e070v;
    Name                                      Null?    Type
    TRKORR                                    NOT NULL VARCHAR2(20)
    TRFUNCTION                                NOT NULL VARCHAR2(1)
    TRSTATUS                                  NOT NULL VARCHAR2(1)
    TARSYSTEM                                 NOT NULL VARCHAR2(10)
    AS4USER                                   NOT NULL VARCHAR2(12)
    AS4DATE                                   NOT NULL VARCHAR2(8)
    AS4TIME                                   NOT NULL VARCHAR2(6)
    STRKORR                                   NOT NULL VARCHAR2(20)
    LANGU                                     NOT NULL VARCHAR2(1)
    AS4TEXT                                   NOT NULL VARCHAR2(60)
    CLIENT                                    NOT NULL VARCHAR2(3)
    SQL>

  • Sql query for running sum(using aggregate)

    <pre>
    Table name table1 (no, amount)
    insert into table1 values(1, 10) ;
    insert into table1 values(2 ,-10) ;
    insert into table1 values(3, -20) ;
    insert into table1 values(4,  -30) ;
    insert into table1 values(5,40) ;
    and i am expecting the result in this manner
    no
    sum (amount)
    1
    10
    2
    0
    3
    -20
    4
    -50
    5
    -10
    select no,sum(amount) over(order by no) from table1;
    but with this query i am getting the result in below manner
    no
    sum (amount)
    1
    10
    2
    20
    3
    40
    4
    70
    5
    110
    which is not excepted result, could some one help me in getting excepted results ,could any one provide the proper query for this
    </pre>

    h
    Hi Friends,
    sorry to trouble you,i did  not have oracle instance installed on my machine to check the query ,
    this is some test query which is some resemblance with actual query in my project
    actually the requirement is like this ,this is the master table 
      NO                            amount
             1                         10
             2                         100
             3                         120
             4                         50
             5                         41
    using some decoding function in the query the result came like this
    NO                        decode(amount,......) quantity
             1                          10
             2                         -10
             3                         -20
             4                         -30
             5                          41
    on this decode function i am trying to using aggregate function SUM,but in that case in stood of giving
    ABS value , it is giving   in proper value like below result
      NO        decode(amount,......) quantity    aggregate sum
             1                          10                10
             2                         -10                20
             3                         -20                40
             4                         -30                70
             5                          41                111
    but i excepted the result  ABS  value like below
       NO           decode(amount,......) quantity    aggregate sum
             1                         10                 10
             2                         -10                0
             3                         -20               -20
             4                         -30               -50
             5                          41                -9
       my question is aggregate function on this decoded values have any impact on the result?
       for this question your are unable to help me ,tomorrow i will get exact table structure and exact query which i am using
       in my project

Maybe you are looking for

  • Help?registerd two ipods on same folder

    This is the dad who does not know nothing,both of my daughters got nanos and i think I registerd them to the same folder.I would like tem seperate.please tell me how. thanks thedad

  • Apple ID needs to be entered every time

    Hi there, Since my update from iOS 5 to iOS5.1.1 I experience that the ipad is asking me permanently for my apple id details when I start or re-launch an app. I find this very annoying. Can sb tell me how I can switch this off? Thx.

  • Xctest/xctest.h file not found

    Hello Support, I have tried to fix this error but I couldn't get success. My Code is as below: UITextviewAppDelegate.m   UITextviewViewController *tic=[[UITextviewViewController alloc]init];   self.window.rootViewController=tic; UITextviewViewControl

  • 2nd LOV in oracle forms

    I have an lov for dept_id, If the user is the not manager of that department, then I populate a message, you are not the supervisor and clear the dept_id field. If the user running the form is the manager, then after choosing the dept_id from the lov

  • Another movie problem

    I just got a new ipod classic 80gb for Christmas. I wanted to download the little clips they have for the movies. I think they call them (vignette) I downloaded one with no problem but when I downloaded the others it said I couldn't do this on this i