Improve performance of query with order by

Hello,
I have a query with a necessary "order by" which lasts 24 seconds. The same query without the "order by" lasts 1 second.
How can I improve the performance of the query with "order by"?
Thank you very much.
The query is:
select distinct CC.acceso,CC.ext_acceso,TIT.TITULO_SALIDA
from (((Ocurrencias CT01 inner join
     palabras p0 on (CT01.cod_palabra = p0.cod_palabra and p0.palabra like 'VENEZUELA%' AND p0.campo = 'AUTOR')) INNER JOIN
     CENTRAL CC ON (CT01.ACCESO = CC.ACCESO AND CT01.EXT_ACCESO = CC.EXT_ACCESO))) inner join
     codtit ctt on (CC.acceso = ctt.acceso and CC.ext_acceso = ctt.ext_acceso) inner join
     titulos tit on (ctt.cod_titulo = tit.cod_titulo and ctt.portada = '1')
where CC.nivel_reg <> 's'
ORDER BY 3 ASC;

My guess is SQL Scratchpad is a GUI and is not returning all the rows but just the first screenful. Without any order by or distinct the database can start returning rows as soon as it finds the first one. With an order or distinct it needs to sort the rows so the first row can only be returned after the last row is retrieved.
Open a command line prompt and run
sqlplus
SQL> set timing on
SQL>And then run your queries.
If you still have a large discrepancy do this
SQL> set autotrace traceonly
SQL>And then run the queries and post the output.

Similar Messages

  • Improving performance of query with View

    Hi ,
    I'm working on a stored procedure where certain records have to be eleminated , unfortunately tables involved in this exception query are present in a different database which will lead to performance issue. Is there any way in SQL Server to store this query
    in a view and store it's execution plan and make it work like sp.While I beleive it's kinda crazy thought but is there any better way to improve performance of query when accessed across databases.
    Thanks,
    Vishal.

    Do not try to solve problems that you have not yet confirmed to exist.  There is no general reason why a query (regardless of whether it involves a view) that refers to a table in a different database (NB - DATABASE not INSTANCE) will perform poorly. 
    As a suggestion, write a working query using a duplicate of the table in the current database.  Once it is working, then worry about performance.  Once that is working as efficiently as it can , change the query to use the "remote" table rather
    than the duplicate. Then determine if you have an issue.  If you cannot get the level of performance you desire with a local table, then you most likely have a much larger issue to address.  In that case, perhaps you need to change your perspective
    and approach to accomplishing your goal. 

  • Query with order by clause

    Hi,
    I found a query with order by clause in procedure which is taking long time.
    Stats are upto date.
    Total Rows :650000.
    It is ordered by primary key column.
    select * from table_name order by col1;
    col1 is a primary key.No of cpu's used is 4.
    can anyone suggest me a better solution to improve the performance of a query.
    Is it better to use parallel hint for above scenario.
    Any help really apprecaited.
    Thanks in advance.

    Hi,
    Thanks for ur immediate reply.
    It doesn't have where clause.
    below is the plan
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 619071987
    | Id  | Operation                   | Name                 | Rows  | Bytes | Cos
    |   0 | SELECT STATEMENT            |                      |   671K|   255M| 125
    |   1 |  TABLE ACCESS BY INDEX ROWID| FULL_ITEM_FACILITIES |   671K|   255M| 125
    |   2 |   INDEX FULL SCAN           | FIF_PK               |   671K|       |
    9 rows selected
    Executed in 0.094 secondsThanks in advance
    Edited by: unique on Jun 22, 2009 8:26 AM

  • How to improve performance of query

    Hi all,
    How to improve performance of query.
    please send :
    [email protected]
    thanks in advance
    bhaskar

    hi
    go through the following links for performance
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/cccad390-0201-0010-5093-fd9ec8157802
    http://www.asug.com/client_files/Calendar/Upload/ASUG%205-mar-2004%20BW%20Performance%20PDF.pdf
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/1955ba90-0201-0010-d3aa-8b2a4ef6bbb2

  • Sub query with order by

    Hi ,
    I have created a sub query with order by on a column.( i have cutomized the IKM control append to put order by).I can see the order by condition.If i use this subquery(yellow interface) in main query(is also yellow interface) i can't see the order by condition
    Subquery(Q-yellow interface):
    select
    PID,
         START_TIME,
         ACTION_TYPE_CODE
    FROM
    select      DISTINCT
         SERVICE_TRACKING_S.PID PID,
         TO_TIMESTAMP(TO_CHAR(SERVICE_TRACKING_S.ACTION_TIME,'DD-MON-YY HH24:MI:SS'),'DD-MON-YY HH24:MI:SS') START_TIME,
         SERVICE_TRACKING_S.ACTION_TYPE_CODE ACTION_TYPE_CODE
    from     KSTGDB.SERVICE_TRACKING_S SERVICE_TRACKING_S
    where          (1=1)     
    ORDER BY-----------------------------------------------
    PID
    ,START_TIME ASC
    ODI_GET_FROM
    Main query(Q1--yellow interface):
    select
    PID,
         START_TIME,
         ACTION_TYPE_CODE,
         RN,
         RN_MAX
    FROM (     
    select      
         Q.PID PID,
         Q.START_TIME START_TIME,
         CASE WHEN Q.START_TIME-LAG(Q.START_TIME,1,Q.START_TIME) OVER (PARTITION BY Q. PID ORDER BY Q.START_TIME)> numtodsinterval(75,'minute')
    or Q.PID!=LAG(Q.PID,1,0) OVER (PARTITION BY Q.PID ORDER BY Q.START_TIME) THEN 1 ELSE Q.ACTION_TYPE_CODE END ACTION_TYPE_CODE,
         ROW_NUMBER() OVER(PARTITION BY Q.PID ORDER BY Q.START_TIME) RN,
         count(*) over (PARTITION BY Q.PID ORDER BY Q.START_TIME ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING )
    RN_MAX
    from     (
    select      DISTINCT
         SERVICE_TRACKING_S.PID PID,     TO_TIMESTAMP(TO_CHAR(SERVICE_TRACKING_S.ACTION_TIME,'DD-MON-YY HH24:MI:SS'),'DD-MON-YY HH24:MI:SS') START_TIME,     SERVICE_TRACKING_S.ACTION_TYPE_CODE ACTION_TYPE_CODE
    from     KSTGDB.SERVICE_TRACKING_S SERVICE_TRACKING_S
    where     (1=1)
    ----------------- i don't see order by here--------------------------------
    ) Q
    where          (1=1)     
    ) ODI_GET_FROM
    thanks in advance
    K

    Hi,
    Add a new KM step with the SQL you want to use for the sub query and select the +"Use Current Command for Derived-Table sub-select statement"+ checkbox. This new step can be the last one of your IKM.
    Basically, you can copy the select statement of the "Insert new rows" step.
    Regards,
    JeromeFr

  • Query with order by taking 1 hr

    Hi,
    Query with order by taking 1 hr, without order by taking 9 seconds,
    pls tell me ,wat will be the reason and how to tune.
    Query:
    SELECT
    T17.CONFLICT_ID,
    T17.LAST_UPD,
    T17.CREATED,
    T17.LAST_UPD_BY,
    T17.CREATED_BY,
    T17.MODIFICATION_NUM,
    T17.ROW_ID,
    T1.ACCNT_TYPE_CD,
    T36.X_BRIDGESTATION,
    T36.X_CTI_PIN,
    T36.X_FLOOR,
    T36.X_SEGMENT2,
    T36.X_SEGMENT3,
    T36.X_CONTACT_STATUS,
    T36.X_DEALING_CODE,
    T36.X_DELETE,
    T36.X_DEPARTMENT,
    T36.X_DIRECT_MKT,
    T36.X_FASS_LAST_CONTACT_DATE,
    T36.X_SEGMENT1,
    T36.X_LAST_TRAINED_DATE,
    T36.X_LEGAL_CONSENT,
    T36.X_LOCAL_FST_NAME,
    T36.X_LOCAL_LAST_NAME,
    T36.X_PREF_LANG,
    T36.X_PROD_BLEND,
    T36.X_SALUTATION,
    T36.X_BSC_SIDE,
    T36.X_END_USR_ACT,
    T36.X_PRIM_ASSET_CLASS,
    T36.X_SEC_ASSET_CLASS,
    T36.X_STATUS,
    T36.X_LANGUAGE,
    T36.X_SUPPRESS_SMS_FLG,
    T36.X_TRAINING_ADDRESS,
    T36.X_UPD_TYPE,
    T36.X_XTRA_UPD,
    T36.X_XTRA_ID,
    T36.X_ESERVICE_USER,
    T36.X_SALES_COMMENTS,
    T36.PR_DEPT_OU_ID,
    T1.INTEGRATION_ID,
    T1.PRTNR_FLG,
    T36.BIRTH_DT,
    T36.CELL_PH_NUM,
    T9.ATTRIB_07,
    T5.LAST_UPD,
    T36.EMAIL_ADDR,
    T36.EMP_FLG,
    T36.FAX_PH_NUM,
    T36.FST_NAME,
    T36.HOME_PH_NUM,
    T36.JOB_TITLE,
    T36.LAST_NAME,
    T36.SEX_MF,
    T36.PER_TITLE,
    T36.MID_NAME,
    T36.OWNER_PER_ID,
    T17.NAME,
    T36.PERSON_UID,
    T36.PRIV_FLG,
    T1.NAME,
    T29.PR_ADDR_ID,
    T36.PR_REP_DNRM_FLG,
    T36.PR_REP_MANL_FLG,
    T36.PR_REP_SYS_FLG,
    T36.PR_MKT_SEG_ID,
    T36.PR_GRP_OU_ID,
    T36.PR_OPTY_ID,
    T36.PR_PER_ADDR_ID,
    T36.PR_PER_PAY_PRFL_ID,
    T36.PR_POSTN_ID,
    T36.PR_RESP_ID,
    T19.OWN_INST_ID,
    T19.INTEGRATION_ID,
    T36.SOC_SECURITY_NUM,
    T29.STATUS,
    T36.SUPPRESS_CALL_FLG,
    T36.SUPPRESS_MAIL_FLG,
    T36.WORK_PH_NUM,
    T36.BU_ID,
    T36.PR_ALT_PH_NUM_ID,
    T36.PR_EMAIL_ADDR_ID,
    T36.PR_SYNC_USER_ID,
    T18.SHARE_HOME_PH_FLG,
    T36.PR_REGION_ID,
    T36.NATIONALITY,
    T36.CITIZENSHIP_CD,
    T36.AGENT_FLG,
    T36.MEMBER_FLG,
    T13.PR_EMP_ID,
    T36.PR_OU_ADDR_ID,
    T33.PR_EMP_ID,
    T13.PR_EMP_ID,
    T21.LOGIN,
    T26.LOGIN,
    T25.PR_FAX_NUM_ID,
    T36.PR_INDUST_ID,
    T36.PR_NOTE_ID,
    T1.PR_POSTN_ID,
    T36.PR_PROD_LN_ID,
    T25.PR_SMS_NUM_ID,
    T36.PR_SECURITY_ID,
    T6.NAME,
    T36.MED_SPEC_ID,
    T36.PR_STATE_LIC_ID,
    T36.PR_TERR_ID,
    T36.PROVIDER_FLG,
    T36.CUST_SINCE_DT,
    T34.ADDR,
    T34.CITY,
    T34.COUNTRY,
    T34.ZIPCODE,
    T34.STATE,
    T4.NAME,
    T36.CURR_PRI_LST_ID,
    T27.ROW_STATUS,
    T22.LOGIN,
    T2.CITY,
    T2.COUNTRY,
    T2.ZIPCODE,
    T2.COUNTY,
    T2.ADDR,
    T20.X_ACC_CLASS,
    T20.X_FS_INLIMITS,
    T20.X_PRIORITY,
    T20.X_DC_LOC,
    T20.X_SERV_PROV_ID,
    T20.X_FS_LOC,
    T20.X_LOCAL_ACCOUNT_NAME,
    T20.NAME,
    T20.LOC,
    T20.PR_BL_ADDR_ID,
    T20.PR_BL_PER_ID,
    T20.PR_SHIP_ADDR_ID,
    T20.PR_SHIP_PER_ID,
    T20.OU_NUM,
    T16.ROW_ID,
    T20.PR_SRV_AGREE_ID,
    T16.ROW_ID,
    T15.PRIM_MARKET_CD,
    T16.ROW_ID,
    T14.CITY,
    T14.COUNTRY,
    T14.ZIPCODE,
    T14.STATE,
    T14.ADDR,
    T35.NAME,
    T32.NAME,
    T8.CHRCTR_ID,
    T32.PRIV_FLG,
    T3.LOGIN,
    T31.LOGIN,
    T36.ROW_ID,
    T36.MODIFICATION_NUM,
    T36.CREATED_BY,
    T36.LAST_UPD_BY,
    T36.CREATED,
    T36.LAST_UPD,
    T36.CONFLICT_ID,
    T36.PAR_ROW_ID,
    T25.ROW_ID,
    T25.MODIFICATION_NUM,
    T25.CREATED_BY,
    T25.LAST_UPD_BY,
    T25.CREATED,
    T25.LAST_UPD,
    T25.CONFLICT_ID,
    T25.PAR_ROW_ID,
    T18.ROW_ID,
    T18.MODIFICATION_NUM,
    T18.CREATED_BY,
    T18.LAST_UPD_BY,
    T18.CREATED,
    T18.LAST_UPD,
    T18.CONFLICT_ID,
    T18.PAR_ROW_ID,
    T9.ROW_ID,
    T9.MODIFICATION_NUM,
    T9.CREATED_BY,
    T9.LAST_UPD_BY,
    T9.CREATED,
    T9.LAST_UPD,
    T9.CONFLICT_ID,
    T9.PAR_ROW_ID,
    T19.ROW_ID,
    T19.MODIFICATION_NUM,
    T19.CREATED_BY,
    T19.LAST_UPD_BY,
    T19.CREATED,
    T19.LAST_UPD,
    T19.CONFLICT_ID,
    T19.PAR_ROW_ID,
    T27.ROW_ID,
    T24.ROW_ID,
    T23.ROW_ID,
    T2.ROW_ID,
    T28.ROW_ID,
    T16.ROW_ID,
    T11.ROW_ID,
    T14.ROW_ID,
    T35.ROW_ID,
    T8.ROW_ID,
    T30.ROW_ID,
    T7.ROW_ID
    FROM
    SIEBEL.S_ORG_EXT T1,
    SIEBEL.S_ADDR_PER T2,
    SIEBEL.S_USER T3,
    SIEBEL.S_PRI_LST T4,
    SIEBEL.S_PER_DEDUP_KEY T5,
    SIEBEL.S_MED_SPEC T6,
    SIEBEL.S_PARTY T7,
    SIEBEL.S_CON_CHRCTR T8,
    SIEBEL.S_CONTACT_X T9,
    SIEBEL.S_POSTN T10,
    SIEBEL.S_CON_ADDR T11,
    SIEBEL.S_POSTN T12,
    SIEBEL.S_POSTN T13,
    SIEBEL.S_ADDR_PER T14,
    SIEBEL.S_ORG_EXT_FNX T15,
    SIEBEL.S_PARTY T16,
    SIEBEL.S_PARTY T17,
    SIEBEL.S_EMP_PER T18,
    SIEBEL.S_CONTACT_SS T19,
    SIEBEL.S_ORG_EXT T20,
    SIEBEL.S_USER T21,
    SIEBEL.S_USER T22,
    SIEBEL.S_CON_ADDR T23,
    SIEBEL.S_PARTY T24,
    SIEBEL.S_CONTACT_LOYX T25,
    SIEBEL.S_USER T26,
    SIEBEL.S_POSTN_CON T27,
    SIEBEL.S_PARTY_PER T28,
    SIEBEL.S_POSTN_CON T29,
    SIEBEL.S_PARTY T30,
    SIEBEL.S_USER T31,
    SIEBEL.S_CHRCTR T32,
    SIEBEL.S_POSTN T33,
    SIEBEL.S_ADDR_PER T34,
    SIEBEL.S_CONTACT_XM T35,
    SIEBEL.S_CONTACT T36
    WHERE
    T36.PR_DEPT_OU_ID = T1.PAR_ROW_ID (+) AND
    T1.PR_POSTN_ID = T33.PAR_ROW_ID (+) AND
    T36.PR_POSTN_ID = T13.PAR_ROW_ID (+) AND
    T17.ROW_ID = T29.CON_ID (+) AND T29.POSTN_ID (+) = '1-ERPTObjMgrSqlLog' AND
    T33.PR_EMP_ID = T21.PAR_ROW_ID (+) AND
    T13.PR_EMP_ID = T26.PAR_ROW_ID (+) AND
    T36.PR_PER_ADDR_ID = T34.ROW_ID (+) AND
    T36.MED_SPEC_ID = T6.ROW_ID (+) AND
    T36.CURR_PRI_LST_ID = T4.ROW_ID (+) AND
    T17.ROW_ID = T5.PERSON_ID (+) AND
    T17.ROW_ID = T36.PAR_ROW_ID AND
    T17.ROW_ID = T25.PAR_ROW_ID (+) AND
    T17.ROW_ID = T18.PAR_ROW_ID (+) AND
    T17.ROW_ID = T9.PAR_ROW_ID AND
    T17.ROW_ID = T19.PAR_ROW_ID (+) AND
    T36.PR_POSTN_ID = T27.POSTN_ID AND T36.ROW_ID = T27.CON_ID AND
    T27.POSTN_ID = T24.ROW_ID AND
    T27.POSTN_ID = T12.PAR_ROW_ID (+) AND
    T12.PR_EMP_ID = T22.PAR_ROW_ID (+) AND
    T36.PR_OU_ADDR_ID = T23.ADDR_PER_ID (+) AND T36.PR_DEPT_OU_ID = T23.ACCNT_ID (+) AND
    T36.PR_OU_ADDR_ID = T2.ROW_ID (+) AND
    T36.PR_DEPT_OU_ID = T28.PARTY_ID (+) AND T36.ROW_ID = T28.PERSON_ID (+) AND
    T36.PR_DEPT_OU_ID = T16.ROW_ID (+) AND
    T36.PR_DEPT_OU_ID = T20.PAR_ROW_ID (+) AND
    T36.PR_DEPT_OU_ID = T15.PAR_ROW_ID (+) AND
    T29.PR_ADDR_ID = T11.ADDR_PER_ID (+) AND T29.CON_ID = T11.CONTACT_ID (+) AND
    T29.PR_ADDR_ID = T14.ROW_ID (+) AND
    T36.X_SEGMENT1 = T35.ROW_ID (+) AND
    T36.PR_MKT_SEG_ID = T8.ROW_ID (+) AND
    T8.CHRCTR_ID = T32.ROW_ID (+) AND
    T1.PR_POSTN_ID = T30.ROW_ID (+) AND
    T1.PR_POSTN_ID = T10.PAR_ROW_ID (+) AND
    T10.PR_EMP_ID = T3.PAR_ROW_ID (+) AND
    T36.PR_SYNC_USER_ID = T7.ROW_ID (+) AND
    T36.PR_SYNC_USER_ID = T31.PAR_ROW_ID (+) AND
    ((T36.X_DELETE = 'N') AND
    (T36.PRIV_FLG = 'N' AND T17.PARTY_TYPE_CD != 'Suspect')) AND
    (T9.ATTRIB_10 = 'NObjMgrSqlLog')
    ORDER BY
    T36.LAST_NAME, T36.FST_NAME

    @afalty, the story you are telling about the order of the tables being important, from smallest to largest, et cetera, is only partially true and only when dealing with the rule based optimizer. Nowadays, almost everybody is using the cost based optimizer, so these remarks can very likely be ignored.
    @original poster:
    I think you are "measuring" the elapsed time by using TOAD, am I right? And you are probably writing 9 seconds, because it took TOAD 9 seconds before it could display the first records. If you would scroll down to the last record, it is likely taking much more time. A sort operation costs resources and time, but very unlikely this much.
    When you want your rows sorted, all rows must have been visited before you know for sure which one is the smallest. That's why it takes longer to display the first row. Without an order by, the query can begin popping out rows much faster.
    Regards,
    Rob.

  • Oracle query tuning : query with Order-by clause

    Hi
    I am having a query in my database :
    SELECT * FROM SAPR3.HRP1001 WHERE "MANDT" = 990
    ORDER BY
    "MANDT" , "OTYPE" , "OBJID" , "PLVAR" , "RSIGN" , "RELAT" , "ISTAT" , "PRIOX" , "BEGDA" , "ENDDA" ,"VARYF" , "SEQNR" ;
    Autotrace output is :
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE (Cost=4649 Card=171895 Byt
    es=22862035)
    1 0 SORT (ORDER BY) (Cost=4649 Card=171895 Bytes=22862035)
    2 1 TABLE ACCESS (FULL) OF 'HRP1001' (Cost=1170 Card=171895
    Bytes=22862035)
    Statistics
    0 recursive calls
    5 db block gets
    12157 consistent gets
    11543 physical reads
    0 redo size
    38253080 bytes sent via SQL*Net to client
    376841 bytes received via SQL*Net from client
    34201 SQL*Net roundtrips to/from client
    0 sorts (memory)
    1 sorts (disk)
    512992 rows processed
    Since it is a issue with order by , it seems a PGA memory issue. there is 12GB PGA available but only 3GB gets allocated. pga_aggregate target is set in the DB. There is a index created for al the columns on order by, but it is not getting used.
    pleas suggest me as I am running into major problems, i can post the output of any query u require from my side. Any help wil be highly apprciated.
    Rishi

    > The query was alwasy spilling over to the One-Parse execution . It can be seen thru ST04N ->resource consumption-> sql work area trace.
    >
    > An undocumented oracle parameter smmmax_size was set which allowed for more usage of physical memory by single process and there was no spillover to the TEMP tablespaces.
    >
    > Also the File read time was analysed from Unix level ( From SAP thru ST04 ->filesystem wait s-> Avg rd (ms) and Ang writes (ms) which showed that reading from the File was not happening well. )
    Hi Rishi,
    the provided execution statistics prove the opposite:
    >Statistics
    >...
    >0 sorts (memory)
    > 1 sorts (disk)
    >512992 rows processed
    This indeed was a single-pass sort, which means it had to use the temp tablespace for one pass of the sorting/grouping.
    Remember that Oracle distinguishes three kinds of sorts: 1. "in memory", 2. "single-pass" and 3. "multi-pass".
    Only the first one won't need to spill out data to the disks. The others do this by definition.
    BTW: the file read times in ST04 are aquired through Oracle V$ views and not directly from the OS - that can make a big difference sometimes.
    regards,
    Lars

  • Query with order by & View/procedure

    1)I have a query its getting joined with few tables and the base table contains 12 billion rows . my issue is when I execute the query with necessary parameter am getting the result in few seconds . but when I add an order by for any column am not getting the result even after 15 minuts.
    The sort column is an indexed column and I have even tried with the primary column of the base table but no change .. is there any way to make it faster with order by ??
    2)I have got a view which also getting joined with few high volume tables . when I call the view with required parameter am not getting the result even after 15 minutes.. but when I took out the query of the view and hardcode the value am getting the result in 3 seconds . so I just made it to a procedure that returns a cursor . now its working fine .. could you please explain me the reason for this ….??
    Please help …

    select * from
    (select Rownum RowNO,Qr.* from
    (select T1.c1,T2.C2,T3.c3 from TI,T2,T3
    where < all required joins>
    order by Ti.c)Qr
    where RowNum <20 )
    where RowNO >10 ;As said before:
    Your view very likely prevented predicate pushing and by manually adding the predicate inside the query, you changed the semantics of the query.
    Your view contains a rownum column. This prevents predicate pushing because the semantics of the query changes. An example to clarify:
    SQL> explain plan
      2  for
      3  select *
      4    from ( select empno
      5                , ename
      6                , sal
      7             from emp
      8         )
      9   where empno = 7839
    10  /
    Uitleg is gegeven.
    SQL> select * from table(dbms_xplan.display)
      2  /
    PLAN_TABLE_OUTPUT
    Plan hash value: 4024650034
    | Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |        |     1 |    14 |     1   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| EMP    |     1 |    14 |     1   (0)| 00:00:01 |
    |*  2 |   INDEX UNIQUE SCAN         | EMP_PK |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("EMPNO"=7839)
    14 rijen zijn geselecteerd.
    SQL> exec dbms_lock.sleep(1)
    PL/SQL-procedure is geslaagd.
    SQL> explain plan
      2  for
      3  select *
      4    from ( select empno
      5                , ename
      6                , sal
      7             from emp
      8            where empno = 7839
      9         )
    10  /
    Uitleg is gegeven.
    SQL> select * from table(dbms_xplan.display)
      2  /
    PLAN_TABLE_OUTPUT
    Plan hash value: 4024650034
    | Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |        |     1 |    14 |     1   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| EMP    |     1 |    14 |     1   (0)| 00:00:01 |
    |*  2 |   INDEX UNIQUE SCAN         | EMP_PK |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("EMPNO"=7839)
    14 rijen zijn geselecteerd.The previous two queries show that in this case the predicate "empno = 7839" can be pushed inside the view. Both queries are semantically the same.
    However, when you add a rownum to your view definition, like you did, the predicates cannot be pushed inside the view:
    SQL> exec dbms_lock.sleep(1)
    PL/SQL-procedure is geslaagd.
    SQL> explain plan
      2  for
      3  select *
      4    from ( select empno
      5                , ename
      6                , sal
      7                , rownum rowno
      8             from emp
      9         )
    10   where empno = 7839
    11  /
    Uitleg is gegeven.
    SQL> select * from table(dbms_xplan.display)
      2  /
    PLAN_TABLE_OUTPUT
    Plan hash value: 2077119879
    | Id  | Operation           | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |      |    14 |   644 |     3   (0)| 00:00:01 |
    |*  1 |  VIEW               |      |    14 |   644 |     3   (0)| 00:00:01 |
    |   2 |   COUNT             |      |       |       |            |          |
    |   3 |    TABLE ACCESS FULL| EMP  |    14 |   196 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("EMPNO"=7839)
    15 rijen zijn geselecteerd.
    SQL> exec dbms_lock.sleep(1)
    PL/SQL-procedure is geslaagd.
    SQL> explain plan
      2  for
      3  select *
      4    from ( select empno
      5                , ename
      6                , sal
      7                , rownum rowno
      8             from emp
      9            where empno = 7839
    10         )
    11  /
    Uitleg is gegeven.
    SQL> select * from table(dbms_xplan.display)
      2  /
    PLAN_TABLE_OUTPUT
    Plan hash value: 1054641936
    | Id  | Operation                     | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT              |        |     1 |    46 |     1   (0)| 00:00:01 |
    |   1 |  VIEW                         |        |     1 |    46 |     1   (0)| 00:00:01 |
    |   2 |   COUNT                       |        |       |       |            |          |
    |   3 |    TABLE ACCESS BY INDEX ROWID| EMP    |     1 |    14 |     1   (0)| 00:00:01 |
    |*  4 |     INDEX UNIQUE SCAN         | EMP_PK |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - access("EMPNO"=7839)
    16 rijen zijn geselecteerd.Now the two queries are not the same anymore. If you wonder why, please look carefully at the query results of both:
    SQL> select *
      2    from ( select empno
      3                , ename
      4                , sal
      5                , rownum rowno
      6             from emp
      7         )
      8   where empno = 7839
      9  /
         EMPNO ENAME             SAL      ROWNO
          7839 KING             5000          9
    1 rij is geselecteerd.
    SQL> select *
      2    from ( select empno
      3                , ename
      4                , sal
      5                , rownum rowno
      6             from emp
      7            where empno = 7839
      8         )
      9  /
         EMPNO ENAME             SAL      ROWNO
          7839 KING             5000          1
    1 rij is geselecteerd.Regards,
    Rob.

  • How to improve query performance when query with mtart

    hi all,
    I need to know what is the best way to query out MATNR when i have values for MTART and WERKS?
    When a user select a MTART and WERKS, a whole bunch of MATNR related to them are display out. How do i improve this query so that it does not take a long time?
    Thanks
    Willliam Wilstroth

    Is that what you are looking for???
    select a~matnr a~mtart ... b~werks ...
           into table <itab>
           from mara as a
           inner join marc as b
           on a~matnr = b~matnr
           where mtart = p_mtart
           and   werks = p_werks.
    There is an index on MTART in table MARA.
    <b>T           Material Type</b>
    Kind Regards
    Eswar

  • How can we improve performance while selection production orders from resb

    Dear all,
    there is a performance issue in a report which compares sales order and production order.
    Below is the code, in this while reading production order data from resb with the below select statement.
    can any body tell me how can we improve the performance? should we use indexing, if yes how to use indexing.
    *read sales order data
      SELECT vbeln posnr arktx zz_cl zz_qty
      INTO (itab-vbeln, itab-sposnr, itab-arktx, itab-zz_cl, itab-zz_qty)
      FROM vbap
      WHERE vbeln  = p_vbeln
      AND   uepos  = p_posnr.
        itab-so_qty = itab-zz_cl * itab-zz_qty / 1000.
        CONCATENATE itab-vbeln itab-sposnr
           INTO itab-document SEPARATED BY '/'.
        CLEAR total_pro.
    **read production order data*
        SELECT aufnr posnr roms1 roanz
        INTO (itab-aufnr, itab-pposnr, itab-roms1, itab-roanz)
        FROM resb
        WHERE kdauf  = p_vbeln
        AND   ablad  = itab-sposnr+2.

    Himanshu,
    Put a break point before these two select statements and execute in the production.This way you will come to know which select statement is taking much time to get executed.
    In both the select statements the where clause is not having the primary keys.
    Coming to the point of selecting the data from vbap do check the SAP note no:-185530 accordigly modify the select statement.
    As far as the table RESB is concerened here also the where clause doesn't have the primary keys.Do check the SAP Note No:-187906.
    I guess not using primary keys is maring the performance.
    K.Kiran.

  • How Can I increase performance of Query with Distinct Keyword

    Dear Experts,
    In my Query when I execute this without Distinct it give result very soon,
    But when I excute this with Distinct its performance is very slow is there any option for increase the performance with Distinct .
    I have to use Distinct according to our rewuirement.

    neither DISTINCT nor GROUP BY do sort. If you need to sort, use ORDER BY. Slight correction, they do a sort, but your results are not guarenteed to be sorted.
    The overhead of a sort is incurred, if your results is large enough (my test below isn't) you will be sorting to disk. Which as we all know can be very slow.
    9i:
    SQL> SET TRIMSPOOL ON
    SQL> CREATE TABLE D (A VARCHAR2(2));
    Table created.
    SQL> INSERT INTO D (A) SELECT DBMS_RANDOM.STRING('U',2) FROM DUAL CONNECT BY LEVEL <= 5000;
    5000 rows created.
    SQL> COMMIT;
    Commit complete.
    SQL> SET AUTOTRACE TRACEONLY EXPLAIN;
    SQL> SELECT DISTINCT A FROM D;
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE
       1    0   SORT (UNIQUE)
       2    1     TABLE ACCESS (FULL) OF 'D'
    SQL> SELECT A FROM D GROUP BY A;
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE
       1    0   SORT (GROUP BY)
       2    1     TABLE ACCESS (FULL) OF 'D'
    SQL> SELECT DISTINCT A FROM D ORDER BY A;
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE
       1    0   SORT (UNIQUE)
       2    1     TABLE ACCESS (FULL) OF 'D'
    SQL> SPOOL OFF10g
    SQL> SET TRIMSPOOL ON
    SQL> CREATE TABLE D (A VARCHAR2(2));
    Table created.
    SQL> INSERT INTO D (A) SELECT DBMS_RANDOM.STRING('U',2) FROM DUAL CONNECT BY LEVEL <= 5000;
    5000 rows created.
    SQL> COMMIT;
    Commit complete.
    SQL> SET AUTOTRACE TRACEONLY EXPLAIN;
    SQL> SELECT DISTINCT A FROM D;
    Execution Plan
    Plan hash value: 3079699766
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |  5000 | 15000 |     7  (29)| 00:00:01 |
    |   1 |  HASH UNIQUE       |      |  5000 | 15000 |     7  (29)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| D    |  5000 | 15000 |     5   (0)| 00:00:01 |
    Note
       - dynamic sampling used for this statement
    SQL> SELECT A FROM D GROUP BY A;
    Execution Plan
    Plan hash value: 2712634873
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |  5000 | 15000 |     7  (29)| 00:00:01 |
    |   1 |  HASH GROUP BY     |      |  5000 | 15000 |     7  (29)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| D    |  5000 | 15000 |     5   (0)| 00:00:01 |
    Note
       - dynamic sampling used for this statement
    SQL> SELECT DISTINCT A FROM D ORDER BY A;
    Execution Plan
    Plan hash value: 1773491675
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |  5000 | 15000 |     8  (38)| 00:00:01 |
    |   1 |  SORT UNIQUE       |      |  5000 | 15000 |     7  (29)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| D    |  5000 | 15000 |     5   (0)| 00:00:01 |
    Note
       - dynamic sampling used for this statement
    SQL> SPOOL OFF

  • JDBC Driver 11.2.0.1.0 freeze after execute query with order by

    Hi,
    I have two tables : A and B
    The table B has as foreign key the ID from table A.
    I'm executing statment select id, foreing_id, name from table b order by foreing_id;
    After executing query I see on database that query remains inactive and I don't receive any response on my client.
    I've activate the oracle driver logs and I notice that driver stop working after these lines
    Dec 26, 2012 7:05:22 PM oracle.jdbc.driver.OracleSql getSqlBytes
    TRACE_30: return: [B@126f827
    Dec 26, 2012 7:05:22 PM oracle.jdbc.driver.OracleSql getSqlBytes
    TRACE_30: Exit
    Dec 26, 2012 7:05:22 PM oracle.jdbc.driver.DBConversion getServerCharSetId
    TRACE_16: Enter:
    Dec 26, 2012 7:05:22 PM oracle.jdbc.driver.DBConversion getServerCharSetId
    TRACE_16: return: 178
    Dec 26, 2012 7:05:22 PM oracle.jdbc.driver.DBConversion getServerCharSetId
    TRACE_16: Exit
    Dec 26, 2012 7:05:22 PM oracle.jdbc.driver.DBConversion getNCharSetId
    TRACE_16: Enter:
    Dec 26, 2012 7:05:22 PM oracle.jdbc.driver.DBConversion getNCharSetId
    TRACE_16: return: 2000
    Dec 26, 2012 7:05:22 PM oracle.jdbc.driver.DBConversion getNCharSetId
    TRACE_16: Exit
    I'm using linux machine to execute this query, and I tried execute this same application in another linux machine and the query works.
    It's very strange, for instance, this only happens if I have two records on table B using the id from table A, and also happens if only one record from table A.
    Could someone help me what's going on with oracle driver?

    LOG ORACLE DRIVER_
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql initialize
    TRACE_30: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql getSqlKind
    TRACE_16: Enter:
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql computeBasicInfo
    TRACE_16: Enter: "SELECT ID, TABLE_A_ID, NAME, URL, ISACTIVE FROM TABLE_B ORDER BY TABLE_A_ID"
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql computeBasicInfo
    TRACE_16: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql getSqlKind
    TRACE_30: return: 0
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql getSqlKind
    TRACE_30: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement prepareForNewResults
    TRACE_16: Enter: true, true
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement clearWarnings
    TRACE_16: Public Enter:
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement clearWarnings
    TRACE_16: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement prepareForNewResults
    TRACE_16: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement doExecuteWithTimeout
    TRACE_16: Enter:
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement doExecuteWithTimeout
    TRACE_20: Debug: needToPrepareDefineBuffer = true
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement doExecuteWithTimeout
    CONFIG: SQL: SELECT ID, TABLE_A_ID, NAME, URL, ISACTIVE FROM TABLE_B ORDER BY TABLE_A_ID
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanOldTempLobs
    TRACE_16: Enter:
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanTempClobs
    TRACE_16: Enter: null
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanTempClobs
    TRACE_16: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanTempBlobs
    TRACE_16: Enter: null
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanTempBlobs
    TRACE_16: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanOldTempLobs
    TRACE_16: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.PhysicalConnection registerHeartbeat
    TRACE_16: Enter:
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.PhysicalConnection registerHeartbeat
    TRACE_16: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.PhysicalConnection needLine
    TRACE_16: Enter:
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.PhysicalConnection needLineUnchecked
    TRACE_16: Enter:
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.PhysicalConnection needLineUnchecked
    TRACE_16: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.PhysicalConnection needLine
    TRACE_16: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection open
    TRACE_16: Enter: oracle.jdbc.driver.T4CStatement@af72d8
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection assertLoggedOn
    TRACE_16: Enter: "T4CConnection.open"
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection assertLoggedOn
    TRACE_16: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement setCursorId
    TRACE_16: Enter: 0
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement setCursorId
    TRACE_16: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection open
    TRACE_16: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement executeMaybeDescribe
    TRACE_16: Enter:
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement executeMaybeDescribe
    TRACE_20: Debug: rowPrefetchChanged = false, needToParse = true, needToPrepareDefineBuffer = true, columnsDefinedByUser = false
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CStatement executeForDescribe
    TRACE_16: Enter:
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection assertLoggedOn
    TRACE_16: Enter: "oracle.jdbc.driver.T4CStatement.execute_for_describe"
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection assertLoggedOn
    TRACE_16: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanOldTempLobs
    TRACE_16: Enter:
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanTempClobs
    TRACE_16: Enter: null
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanTempClobs
    TRACE_16: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanTempBlobs
    TRACE_16: Enter: null
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanTempBlobs
    TRACE_16: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleStatement cleanOldTempLobs
    TRACE_16: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection assertLoggedOn
    TRACE_16: Enter: "oracle.jdbc.driver.T4CStatement.doOall8"
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection assertLoggedOn
    TRACE_16: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection sendPiggyBackedMessages
    TRACE_16: Enter:
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection sendPiggyBackedClose
    TRACE_16: Enter:
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection sendPiggyBackedClose
    TRACE_16: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.T4CConnection sendPiggyBackedMessages
    TRACE_16: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql getSqlBytes
    TRACE_16: Enter: true, false
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql getSql
    TRACE_16: Enter: true, false
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql parse
    TRACE_16: Enter: "SELECT ID, TABLE_A_ID, NAME, URL, ISACTIVE FROM TABLE_B ORDER BY TABLE_A_ID"
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql skipSpace
    TRACE_16: Enter:
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql skipSpace
    TRACE_30: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql handleODBC
    TRACE_16: Enter: NORMAL
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql handleODBC
    TRACE_30: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql parse
    TRACE_16: return: SELECT ID, TABLE_A_ID, NAME, URL, ISACTIVE FROM TABLE_B ORDER BY TABLE_A_ID
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql parse
    TRACE_16: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql getSql
    TRACE_30: return: SELECT ID, TABLE_A_ID, NAME, URL, ISACTIVE FROM TABLE_B ORDER BY TABLE_A_ID
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql getSql
    TRACE_30: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.DBConversion StringToCharBytes
    TRACE_16: Enter: "SELECT ID, TABLE_A_ID, NAME, URL, ISACTIVE FROM TABLE_B ORDER BY TABLE_A_ID"
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.DBConversion StringToCharBytes
    TRACE_16: return: [B@289d2e
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.DBConversion StringToCharBytes
    TRACE_16: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql getSqlBytes
    TRACE_30: return: [B@289d2e
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.OracleSql getSqlBytes
    TRACE_30: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.DBConversion getServerCharSetId
    TRACE_16: Enter:
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.DBConversion getServerCharSetId
    TRACE_16: return: 178
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.DBConversion getServerCharSetId
    TRACE_16: Exit
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.DBConversion getNCharSetId
    TRACE_16: Enter:
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.DBConversion getNCharSetId
    TRACE_16: return: 2000
    Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.DBConversion getNCharSetId
    TRACE_16: Exit
    DDL TABLE A*
    CREATE TABLE "TABLE_A"
    (     "ID" NUMBER NOT NULL ENABLE,
         "NAME" VARCHAR2(50 BYTE) NOT NULL ENABLE,
         "TYPE" NUMBER NOT NULL ENABLE,
         "VERSION" VARCHAR2(30 BYTE) NOT NULL ENABLE,
         "ISIMPLIED" NUMBER(1,0),
         CONSTRAINT "TABLE_A_PK" PRIMARY KEY ("ID")
    USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
    TABLESPACE "APPDATA" ENABLE
    ) SEGMENT CREATION IMMEDIATE
    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
    TABLESPACE "APPDATA" ;
    CREATE UNIQUE INDEX "TABLE_A_NAME_UNIQ" ON "TABLE_A" ("NAME")
    PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
    TABLESPACE "APPDATA" ;
    CREATE UNIQUE INDEX "TABLE_A_PK" ON "TABLE_A" ("ID")
    PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
    TABLESPACE "APPDATA" ;
    DDL Table B:_
    CREATE TABLE "TABLE_B"
    (     "ID" NUMBER NOT NULL ENABLE,
         "TABLE_A_ID" NUMBER NOT NULL ENABLE,
         "NAME" VARCHAR2(50 BYTE) NOT NULL ENABLE,
         "URL" VARCHAR2(2000 BYTE) NOT NULL ENABLE,
         "ISACTIVE" NUMBER(1,0) NOT NULL ENABLE,
         CONSTRAINT "TABLE_B_PK" PRIMARY KEY ("ID")
    USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
    TABLESPACE "APPDATA" ENABLE,
         CONSTRAINT "TABLE_A_FK" FOREIGN KEY ("TABLE_A_ID")
         REFERENCES "TABLE_A" ("ID") ON DELETE CASCADE ENABLE
    ) SEGMENT CREATION IMMEDIATE
    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
    TABLESPACE "APPDATA" ;
    CREATE UNIQUE INDEX "TABLE_B_NAME_UNIQ" ON "TABLE_B" ("NAME")
    PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
    TABLESPACE "APPDATA" ;
    CREATE UNIQUE INDEX "TABLE_B_PK" ON "TABLE_B" ("ID")
    PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
    TABLESPACE "APPDATA" ;
    Comments*_
    After line: Dec 27, 2012 11:33:38 AM oracle.jdbc.driver.DBConversion getNCharSetId TRACE_16: Exit the driver freeze.
    I can see on DB that query keep INACTIVE and oracle driver doesn't throws any exception.
    My Oracle version is 11.2.0.1.0 and as well as oracle driver, I also tried use the version 11.2.0.3.0 but the problem persists.
    More facts:
    If I remove or replace by another field the clause order by TABLE_A_ID from query the query works.
    In this case, I have two recods on TABLE_B with TABLE_A_ID equals 2, if I remove one of these records the query works.
    The bug happens only one specific machine where the number of routers is bigger than another machine that works with all possible scenarios.
    Edited by: 978737 on Dec 27, 2012 12:11 PM

  • EJB finder query with ORDER BY clause

    Hi,
    How to query the data in ordered list using Order By clause in the entity Bean.
    Here is the part of My code in which i am interrested.
    /* @ejbgen:finder
    * signature = "Collection findAllData()"
    * ejb-ql = "SELECT OBJECT(z) FROM DataProfileBean AS z"
    abstract public class DataProfileBean extends EntityAdapter {
    * @ejbgen:cmp-field column = DATA_PREFIX
    * @ejbgen:primkey-field
    * @ejbgen:local-method transaction-attribute = Required
    public abstract Integer getDataPrefix();
    public abstract void setDataPrefix(Integer DataPrefix);
    Now what modification needs to be done in the ejb-ql query to find the DataPrefix in the sorted list.
    Regards,
    Dilip

    I don't think the current spec for EJBs support ORDER BY. But Weblogic has an extension that you can use (that is, if you're using it). Here's the info: http://e-docs.bea.com/wls/docs61/ejb/cmp.html#1076421

  • Improve performance on computers with more than 1 GB RAM (Photoshop CS2)

    Photoshop CS2 uses complex memory management procedures. On computers with 1 GB of RAM, or more, you can optimize Photoshop to take advantage of the quantity of RAM in your system to manage memory more efficiently. For further information on how to implement the "Bigger Tiles" Plug-in please refer to Adobe Knowledgebase
    Document 331372

    Hi,
    1 to 8 GB for process is little on the higher side :) Y don't you try to "page" it up like windows.. Serialize the memory intensive objects into a folder and load them (unserialize) when they are required...
    Just a suggestion and not exactly answering your qn. ..But just thought will post this comment ... Hope it gives some insight..
    Cheers,
    Chandra

  • Query builder 'order by'

    Hi all,
    I'm using query builder to retrieve result. Generated query statement is:
         /jcr:root/content/dam/myFolder//element(*, dam:Asset) order by jcr:content/metadata/general/@views descending
    The attribute 'views' is of xtype numberfield, but of course numberfield is a textfield with only numbers allowed inside and stored as String.
    Ordering by this attribute returns hits ordered in descending alphabetical order.
    My question is if it's possible to execute query with ordering by number value of it's attribute, not string value.
    Thanks a lot for help

    The xpath search cannot do this. So the best option (also in terms of performance) is to make that property a LONG.
    Alternatively you can write a custom querybuilder predicate evaluator that can provide a custom comparator. In the query, you would then address that predicate in the orderby to use the comparator:
    stringasnumber=jcr:content/metadata/general/views
    orderby=stringasnumber
    It could inherit from the standard JcrPropertyPredicateEvaluator or even from RangePropertyPredicateEvaluator (to support range queries as well, using filtering). Note that such a comparator will be slow if there are many results to order (since it does not make use of any search index).

Maybe you are looking for

  • How do I get my Apple ID off my daughters iPhone that I gave her as a present? She Can't update anything without it going to my Apple ID password entry screen.

    I need to get my Apple ID off of my old iPhone 5. I gifted my old iPhone 5 to my daughter as I got the new iPhone 6. I of course have no problems but my daughter can't update anything really without the store telling her to enter my password for my A

  • Can't download Help in Captivate 5

    I cannot open any help files.  I have uninstalled and reinstalled the Help application twice.  It doesn't think I am connected to the internet, but I am.  The Captivate help file is showing pending download and I can't get it to update no matter what

  • Sending pdf via email: pdf is not returned from function module

    Hi all. I am having trouble sending a pdf form as an attachment to an email. After calling the funtion module that is creating the PDF, field pdf of the return parameter /1bcdwb/formoutput should be used to create the attachment. But the field PDF is

  • Psi problem with registration

    Hey. I wanted to create a Psi user to be able to use iChat for my MSN account. Unfortunately, when I try to create an account I get the following error: +There was an error registering the account.+ +Reason: Forbidden.+ +The requesting entity does no

  • Google Docs error in Safari

    I've started receiving strange error in Safari 8 (Yosemite) when opening a Google Document: https://docs.google.com This error has been reported to Google and we'll into it as soon as possible. Please reload this page to continue Reloading does not h